RFC: Use provided type to create the dstTable rather than inferring from the SQL types #1872

Merged
lunny merged 18 commits from zeripath/xorm:dump-infer-from-type into master 2021-05-07 01:19:04 +00:00
Contributor

When using dumptables to convert between dialects if a struct is provided we should use it to generate the SQL types rather than infer them by mapping from the sql types.

Signed-off-by: Andrew Thornton art27@cantab.net

When using dumptables to convert between dialects if a struct is provided we should use it to generate the SQL types rather than infer them by mapping from the sql types. Signed-off-by: Andrew Thornton <art27@cantab.net>
zeripath added 1 commit 2021-02-28 16:11:21 +00:00
Use provided type to create the dstTable rather than inferring from the SQL types
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks reported errors
continuous-integration/drone/pr Build was killed
6d1aba4e23
Author
Contributor

In Gitea we read of reports of bool types being misconverted when converting between different dialect types. This is because the original DumpTables code only inferred the new destination type from the source table's sql type - not the actual field type.

This PR suggests if there is a Type associated with the Table we generate the destination column types from that table Type.

In Gitea we read of reports of bool types being misconverted when converting between different dialect types. This is because the original DumpTables code only inferred the new destination type from the source table's sql type - not the actual field type. This PR suggests if there is a Type associated with the Table we generate the destination column types from that table Type.
Owner
make test-sqlite#TestDumpTables

failed

=== CONT  TestDumpTables
    engine_test.go:159:
        	Error Trace:	engine_test.go:159
        	Error:      	Received unexpected error:
        	            	dest should be a struct's pointer
        	Test:       	TestDumpTables
``` make test-sqlite#TestDumpTables ``` failed ``` === CONT TestDumpTables engine_test.go:159: Error Trace: engine_test.go:159 Error: Received unexpected error: dest should be a struct's pointer Test: TestDumpTables ```
zeripath added 1 commit 2021-04-07 16:14:11 +00:00
Merge branch 'master' into dump-infer-from-type
Some checks failed
continuous-integration/drone/pr Build is failing
d1be010b1d
zeripath added 2 commits 2021-04-07 16:34:03 +00:00
fix test bug
Signed-off-by: Andrew Thornton <art27@cantab.net>
3ff3839b59
Merge branch 'dump-infer-from-type' of gitea.com:zeripath/xorm into dump-infer-from-type
Some checks reported errors
continuous-integration/drone/pr Build was killed
aff1ae8d3f
Author
Contributor

I've fixed the reflection bug - sorry about leaving this one to stew for a while.

I've fixed the reflection bug - sorry about leaving this one to stew for a while.
zeripath added 1 commit 2021-04-08 10:20:35 +00:00
lunny added 1 commit 2021-04-10 05:06:58 +00:00
Merge branch 'master' into dump-infer-from-type
Some checks failed
continuous-integration/drone/pr Build is failing
2e53ce7454
lunny added 1 commit 2021-04-11 08:47:32 +00:00
lunny added 1 commit 2021-04-11 16:29:24 +00:00
Author
Contributor

Looks like this change requires that we set parseTime=true on the connection string for mysql.

Is that acceptable @lunny ?

I suspect that there will be other bugs that are hidden and underlying that also require this - but I'm not certain.

OK I've managed to change to use a different thing.

~~Looks like this change requires that we set parseTime=true on the connection string for mysql.~~ ~~Is that acceptable @lunny ?~~ ~~I suspect that there will be other bugs that are hidden and underlying that also require this - but I'm not certain.~~ OK I've managed to change to use a different thing.
zeripath added 2 commits 2021-04-11 21:03:15 +00:00
set parseTime=true
Signed-off-by: Andrew Thornton <art27@cantab.net>
fed511cc66
Owner

MsSQL test failed.

    engine_test.go:168: 
82s
494	        	Error Trace:	engine_test.go:168
82s
495	        	Error:      	Received unexpected error:
82s
496	        	            	mssql: Invalid column name 'true'.
82s
497	        	Test:       	TestDumpTables
MsSQL test failed. ``` engine_test.go:168: 82s 494 Error Trace: engine_test.go:168 82s 495 Error: Received unexpected error: 82s 496 mssql: Invalid column name 'true'. 82s 497 Test: TestDumpTables ```
Author
Contributor

grargh! this works locally!! - Oh it's MSSQL not MySQL. Let's try again!

grargh! this works locally!! - Oh it's MSSQL not MySQL. Let's try again!
zeripath added 1 commit 2021-04-12 11:43:57 +00:00
Handle bools in MSSQL
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks failed
continuous-integration/drone/pr Build is failing
de0cf1c553
zeripath added 1 commit 2021-04-12 11:55:47 +00:00
better
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks failed
continuous-integration/drone/pr Build is failing
4322c59c4f
zeripath added 1 commit 2021-04-12 14:21:12 +00:00
tidb also needs parseTime too
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks failed
continuous-integration/drone/pr Build is failing
3a1b5ce682
zeripath added 1 commit 2021-04-12 14:35:31 +00:00
remove fprintf
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks failed
continuous-integration/drone/pr Build is failing
efebf2525f
Author
Contributor

OK so I think I need to move code from session.Get() into convert.go to make this possible. - Done

OK so I think I need to move code from `session.Get()` into convert.go to make this possible. - Done
zeripath added 1 commit 2021-04-12 18:39:34 +00:00
use session for import
Signed-off-by: Andrew Thornton <art27@cantab.net>
Some checks failed
continuous-integration/drone/pr Build is failing
d64cf2f2d2
zeripath added 1 commit 2021-04-20 16:49:49 +00:00
zeripath added 1 commit 2021-04-20 18:26:07 +00:00
ugh
Signed-off-by: Andrew Thornton <art27@cantab.net>
ed8e7e426a
zeripath added 1 commit 2021-04-20 19:27:07 +00:00
Fix mssql timezone
Signed-off-by: Andrew Thornton <art27@cantab.net>
All checks were successful
continuous-integration/drone/pr Build is passing
26cbce14e0
Author
Contributor

@lunny looks like this may finally be passing tests!

I just need to check that the dumps it is producing actually are correct.

@lunny looks like this may finally be passing tests! I just need to check that the dumps it is producing actually are correct.
Author
Contributor

I think I've got it and that the times are now correct.

I guess it would be useful to try building a gitea with this to ensure that the dump is now completely correct there.

I'm not completely au fait with the magic of go.mod aliasing so if you're able to do that easily that would be best but I can try to figure it out if you want me to have a go.

I think I've got it and that the times are now correct. I guess it would be useful to try building a gitea with this to ensure that the dump is now completely correct there. I'm not completely au fait with the magic of go.mod aliasing so if you're able to do that easily that would be best but I can try to figure it out if you want me to have a go.
Owner

Since all tests PASS, let's merge it and test it with Gitea.

Since all tests PASS, let's merge it and test it with Gitea.
lunny merged commit 912c2524f8 into master 2021-05-07 01:19:04 +00:00
lunny added the
kind
bug
label 2021-05-07 01:22:27 +00:00
zeripath deleted branch dump-infer-from-type 2021-05-07 22:25:36 +00:00
Author
Contributor

This isn't correct - as the dump doesn't work on Gitea. Sorry - you beat me to it.

This isn't correct - as the dump doesn't work on Gitea. Sorry - you beat me to it.
Author
Contributor

OK so the issue is convert.Conversion types are failing to be handled correctly.

OK so the issue is convert.Conversion types are failing to be handled correctly.
Sign in to join this conversation.
No description provided.