Commit Graph

1532 Commits

Author SHA1 Message Date
Andrew Thornton 912c2524f8 RFC: Use provided type to create the dstTable rather than inferring from the SQL types (#1872)
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>

Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1872
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-05-07 09:19:03 +08:00
Lunny Xiao ce2a743e88 Fix comments (#1896)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1896
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-12 16:00:07 +08:00
Lunny Xiao bd9535d781 Fix comments (#1893)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1893
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-12 09:19:08 +08:00
Lunny Xiao 1ade49614b More tests (#1890)
replace #1585

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1890
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-11 23:41:20 +08:00
Lunny Xiao 60cc3eaaf0 Unsigned Support (#1889)
This PR add support to MySQL, for other databases unsigned type will be downgrade to the related signed type.

Replace #1810

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1889
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-11 16:47:04 +08:00
Lunny Xiao 4bfe6853f5 Fix some comments lint and bug (#1888)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1888
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-10 10:57:36 +08:00
Lunny Xiao b92d951eac Fix drone (#1842)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1842
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-10 09:45:18 +08:00
Lunny Xiao ee78664413 Fix sqlite test (#1887)
Fix bug

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1887
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-04-08 21:26:21 +08:00
Andrew Thornton 2142e31d95 Fix formatting (#1886)
Fix newline formatting

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1886
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-04-08 20:51:48 +08:00
Andrew Thornton 21881d8b84 MariaDB 10.5 adds a suffix on old datatypes (#1885)
MariaDB when encountering an old datetime type will add a suffix of /* mariadb-5.3 */
on its schema information page. Xorm does not understand this and then its mappings
fail.

The simplest solution is just to remove any fixed suffix and that is what this PR does
- a clever solution would look for and remove any comments or match them.

See https://mariadb.com/kb/en/time/ for more details about the comment.

Related: https://github.com/go-gitea/gitea/issues/15277

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1885
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-04-08 14:12:40 +08:00
Lunny Xiao 40ee326cac More clear for Get with nil (#1879)
Resolve #1844

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1879
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-23 21:48:58 +08:00
Lunny Xiao 9286f29576 Fix bug on import when split SQLs (#1878)
Fix #1876

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1878
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-23 21:34:42 +08:00
Lunny Xiao e660414278 Support modernc.org/sqlite (#1850)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1850
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-03-15 23:34:33 +08:00
4color a7a51533d1 fix oracle insert datetime (#1873)
oracle下的日期插入问题。

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1873
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: 4color <4color@noreply.gitea.io>
Co-committed-by: 4color <4color@noreply.gitea.io>
2021-03-04 23:40:35 +08:00
clannadxr eed7e65bd9 Panic when setting wrong logger (#1868)
Co-authored-by: clannadxr <clannadxr@hotmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1868
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: clannadxr <clannadxr@noreply.gitea.io>
Co-committed-by: clannadxr <clannadxr@noreply.gitea.io>
2021-02-18 17:14:13 +08:00
clannadxr 407da9ddd8 export tag identifier (#1865)
#1864 Export tag identifier so we can change that form `xorm` to others

This will be useful when in some migration scenarios such as migrate `sqlx` to `xorm`, the former uses `db` as the identifier and has a very simple rule which can be covered by xorm parser rules

Co-authored-by: clannadxr <clannadxr@hotmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1865
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: clannadxr <clannadxr@noreply.gitea.io>
Co-committed-by: clannadxr <clannadxr@noreply.gitea.io>
2021-02-09 15:20:54 +08:00
whybangbang ffac8e3577 session add method IsInTx (#1863)
Co-authored-by: whybangbang <525484036@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1863
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: whybangbang <whybangbang@noreply.gitea.io>
Co-committed-by: whybangbang <whybangbang@noreply.gitea.io>
2021-02-03 23:27:07 +08:00
Lunny Xiao 4629bb1717 Add NewEngineWithDB (#1860)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1860
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-02-02 14:15:10 +08:00
Lunny Xiao d41a13b562
Fix tests 2021-01-28 11:17:33 +08:00
Lunny Xiao 7c61c09af7 Revert "Automatically convert datetime to int64 (#1715)"
This reverts commit 8284e5defa.
2021-01-28 11:03:43 +08:00
Lunny Xiao 7cd51d58fa Upgrade builder to v0.3.8 (#1855)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1855
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-28 10:56:03 +08:00
Lunny Xiao b1297535f6 Merge branch 'master' of gitea.com:xorm/xorm 2021-01-21 15:12:38 +08:00
Lunny Xiao 34f68a05eb
Release v1.0.7 2021-01-21 15:10:21 +08:00
Lunny Xiao 6f4b2fd80e Fix bug for mssql (#1854)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1854
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-21 15:08:48 +08:00
L-Angel c442c5a9a8 fix_bugs_for_mssql (#1852)
1. add: support xml column type for mssql.
2. fix: array index overflow when getindexs caused by unregular indexname(eg.idx_(tablename))

Co-authored-by: Rick <lonelyangel.jcw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1852
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: L-Angel <l-angel@noreply.gitea.io>
Co-committed-by: L-Angel <l-angel@noreply.gitea.io>
2021-01-19 13:41:14 +08:00
Lunny Xiao 91e0b9aa6e
Add changelog 2021-01-05 11:06:15 +08:00
Lunny Xiao 8284e5defa Automatically convert datetime to int64 (#1715)
Fix #1714

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1715
Reviewed-by: Jerry <jerry@noreply.gitea.io>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 11:04:22 +08:00
Lunny Xiao 26b248c569 Fix update bug (#1823)
Fix #1821

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1823
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 10:55:36 +08:00
Lunny Xiao b65276da85 Fix index (#1841)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1841
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 10:42:14 +08:00
Lunny Xiao 7c8d3f1ad9 Fix bug when modify column on mssql (#1849)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1849
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-01-05 10:37:41 +08:00
finelog 3472d80a6d prevent panic when struct with unexport field (#1839)
prevent panic when struct with unexport field

add test for prevent panic when vanial struct with unexport field panic

minor code fix

minor fix part II

Co-authored-by: finelog <kaicltw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1839
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: finelog <finelog@noreply.gitea.io>
Co-Committed-By: finelog <finelog@noreply.gitea.io>
2020-12-02 22:07:35 +08:00
Lunny Xiao acb337ba1f Fix find and count bug with cols (#1826)
Fix find and count bug with cols

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1826
Co-Authored-By: Lunny Xiao <xiaolunwen@gmail.com>
Co-Committed-By: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-09 12:23:14 +08:00
Lunny Xiao beac298c02 Fix json tag with other type (#1822)
Fix json tag with other type

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1822
Co-Authored-By: Lunny Xiao <xiaolunwen@gmail.com>
Co-Committed-By: Lunny Xiao <xiaolunwen@gmail.com>
2020-11-03 17:10:35 +08:00
jumpeiMano 17f28a1314 feat: define xorm.FromDialectAndDB (#1812)
refactor: rename the function name

feat: define xorm.FromDialectAndDB

Co-authored-by: jumpeiMano <jumpeim37@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1812
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-Authored-By: jumpeiMano <jumpeimano@noreply.gitea.io>
Co-Committed-By: jumpeiMano <jumpeimano@noreply.gitea.io>
2020-10-20 11:11:04 +08:00
Lunny Xiao 0c1b815227 Performance improvement for columnsbyName (#1788)
Performance improvement for columnsbyName

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1788
2020-09-09 13:44:18 +00:00
Lunny Xiao e35662b1ed
Change log for v1.0.5 2020-09-08 23:42:39 +08:00
Lunny Xiao 1b200bdcba Fix bug of ToDB when update on a nil pointer (#1786)
Fix test

Fix bug

Fix bug

Add test for insert nil struct field

Fix test

Fix bug of ToDB when update on a nil pointer

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1786
2020-09-08 15:40:26 +00:00
Andrew Thornton b422930617 Fix warnings with schema Sync2 with default varchar as NVARCHAR (#1783)
prod CI

Merge branch 'fix-1782-MSSQL-nvarchar-fixes' of gitea.com:zeripath/xorm into fix-1782-MSSQL-nvarchar-fixes

map "character" to Char for postgres

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

Merge branch 'master' into fix-1782-MSSQL-nvarchar-fixes

Postgres (and cockroachDB by inheritance) maps Char to Varchar

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

fix test

Add a few more column testcases in light of postgres weirdness

prod CI

prod CI

prod CI

Properly handle MAX

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

Add tests for Test and Char columns

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

prod CI

fix test

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

Remove the duplicate mssql drone test and add a specific sync test

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

add depends_on (2)

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

add depends_on

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

add nvarchar as a testcase

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

Set defaultVarchar to upper case

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

Fix length issue

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

schemas.Text should map to db.defaultVarchar

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

Add failing test

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1783
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-08 01:36:50 +00:00
lafriks 01e1e98dd5 Do not ever quote asterisk symbol. Fixes #1780 (#1781)
Do not ever quote asterisk symbol. Fixes #1780

Co-authored-by: Lauris BH <lauris@nix.lv>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1781
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-06 08:22:34 +00:00
Lunny Xiao 3e0179ff26 Fix bug on get columns for postgres (#1779)
Fix bug on get columns for postgres

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1779
2020-09-03 13:10:27 +00:00
Lunny Xiao b10919ec56
Add changelog for v1.0.4 2020-09-02 20:40:16 +08:00
Andrew Thornton f8c91ec4a3 Correct default detection in MariaDB >= 10.2.7 (#1778)
try again ci

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

try again ci

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

tidy up appearance of the alreadyQuoted SQL string

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

Merge remote-tracking branch 'origin/master' into fix-defaults-sync2-mysql

Try MariaDB 10.4

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

fix drone

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

Correct default detection in MariaDB >= 10.2.7

MariaDB in version 10.2.7 changed the reporting of COLUMN_DEFAULT in
INFORMATION_SCHEMA.COLUMNS to quote string values.

This PR adds a version detection test to the columns query.

References: https://jira.mariadb.org/browse/MDEV-13132
References: https://jira.mariadb.org/browse/MDEV-15390

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1778
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-02 12:37:16 +00:00
jdkendall 76d6b9fdf5 Fix mysql dialect error from invalid db identifier in orderby clause (#1743) (#1751)
Fix mysql dialect error from invalid db identifier in orderby clause (#1743)

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1751
2020-08-31 01:19:12 +00:00
w3xse7en f39a4cb41c solve duplicate log in commit and rollback (#1750)
solve duplicate log in commit and rollback

Co-authored-by: Lyi <zhanghong@zuodashi.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1750
Reviewed-by: helong zhang <outman99@hotmail.com>
2020-07-30 09:05:59 +00:00
sylba2050 4a6b8c29bf Fix typo (#1748)
Fix typo

Co-authored-by: Masataka Hisasue <masataka.hisasue@optim.co.jp>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1748
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-27 09:29:33 +00:00
appleboy fe3bc3851e chore: enable fmt check (#1742)
chore: enable fmt check

Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1742
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-21 04:36:55 +00:00
Lunny Xiao 318102c9ff Add params for mssql to allow redefine varchar as nvarchar or char as nchar (#1741)
Update drone test for mssql nvarchar

Add params for mssql to allow redefine varchar as nvarchar or char as nchar

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1741
2020-07-18 08:01:27 +00:00
Thomas_An 0fae64bb3b Support get dataSourceName on ContextHook for monitor which DB executed SQL (#1740)
Merge branch 'log_context_add_db_info'

add session to context

Revert "accept lunny's suggestion"

This reverts commit 57fd669942.

Merge branch 'master' of https://gitea.com/Thomas_An/thomasan_xorm

accept lunny's suggestion

Merge branch 'master' into master

add test code

session add Engine func

Used to monitor which DB executed this SQL

Co-authored-by: yong.an <yong.an@shopee.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1740
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-07-13 13:29:38 +00:00
Lunny Xiao 946fb57e1c
Add 1.0.3 to changelog 2020-07-10 20:57:00 +08:00
StdioA be7800fc63 Fix index name parsing in SQLite dialect (#1737)
Fix index name parsing in SQLite dialect

If index is created with statement like CREATE INDEX "IDX_tbl_field" ON "tbl" (field), the dialect will parse index name as "IDX_tbl_field" and recognize it as an irregular index.

Co-authored-by: David Dai <stdioa@163.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1737
2020-07-09 08:26:18 +00:00