Commit Graph

64 Commits

Author SHA1 Message Date
Andrew Thornton ad4830f531 Remove default length of 50 for Blob (#1959)
There is an odd inconsistency with default blob sizes - this PR only sets the
default size for bytea and binary.

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1959
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-07-23 08:59:53 +08:00
Lunny Xiao e323971011 refactor some code (#2000)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/2000
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-21 00:12:20 +08:00
Lunny Xiao a7e010df2d refactor insert condition generation (#1998)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1998
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-20 13:46:24 +08:00
Lunny Xiao 86775af2ec refactor and add setjson function (#1997)
Fix #1992

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1997
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-19 13:43:53 +08:00
Lunny Xiao aaa2111e8f Refactor asbytes (#1995)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1995
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-19 00:21:46 +08:00
Lunny Xiao b296c8f1d7 Exec with time arg now will obey time zone settings on engine (#1989)
Fix #1770

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1989
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-14 12:20:26 +08:00
Lunny Xiao 717e4a0d21 Add database alias table and fix wrong warning (#1947)
fix #1831

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1947
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 17:09:40 +08:00
Lunny Xiao b754e78269 Support big.Float (#1973)
Now you can use big.Float for numeric type.

```go
type MyMoney struct {
	Id int64
    Money big.Float `xorm:"numeric(22,2)"`
}
```

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1973
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 14:00:16 +08:00
Lunny Xiao bb91a0773c Fix postgres genScanResult (#1972)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1972
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-07 11:34:33 +08:00
Lunny Xiao a5030dc7a4 refactor get (#1967)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1967
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-06 16:06:04 +08:00
Lunny Xiao d0e5dba40e Query interface (#1965)
refactor query interface

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1965
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-07-04 21:23:17 +08:00
antialiasis 44f892fddc Ignore comments when deciding when to replace question marks. #1954 (#1955)
This should solve #1954 and adds some tests for it. I will note I'm not 100% clear on whether there are other edge cases that should be covered here. From what I understand the only standard SQL way to escape single quotes is to double them, which shouldn't cause any problems with this, but if some SQL flavors allow other kinds of escaping, for instance, that would probably need to be covered too for ideal results.

Co-authored-by: Hlín Önnudóttir <hlin@nanitor.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1955
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: antialiasis <antialiasis@noreply.gitea.io>
Co-committed-by: antialiasis <antialiasis@noreply.gitea.io>
2021-06-26 19:19:13 +08:00
knice88 9461461967 fix pg GetColumns missing comment (#1949)
xorm reverse生成的结构体缺少备注信息

Co-authored-by: chad <example@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1949
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: knice88 <knice88@noreply.gitea.io>
Co-committed-by: knice88 <knice88@noreply.gitea.io>
2021-06-12 22:47:15 +08:00
Lunny Xiao 7fd6356a85 Add DBVersion (#1723)
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1723
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-12 15:06:05 +08:00
Lunny Xiao 0907b7a7fd test for unsigned int32 (#1923)
To confirm #722 has been resolved.

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1923
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-12 13:27:56 +08:00
Lunny Xiao a6d2bfb4ba Compitable with cockroach (#1930)
Fix #1292

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1930
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-committed-by: Lunny Xiao <xiaolunwen@gmail.com>
2021-06-09 14:07:34 +08:00
janse_zyd b1449d0fb7 Replace goracle with godror (#1914)
Co-authored-by: janse_zyd <59941594@qq.com>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1914
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: janse_zyd <janse_zyd@noreply.gitea.io>
Co-committed-by: janse_zyd <janse_zyd@noreply.gitea.io>
2021-06-06 21:34:02 +08:00
Andrew Thornton d2f52eba64 Byte strings in postgres aren't 0x... (#1906)
Byte strings in postgres are actually E'\x...' not 0x...

This is part of the follow-up to #1872

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

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1906
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: Andrew Thornton <art27@cantab.net>
Co-committed-by: Andrew Thornton <art27@cantab.net>
2021-05-09 15:09:59 +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 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
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 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
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 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
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
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
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
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
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
Lunny Xiao 1a39682180 Fix dump of sqlite (#1639)
Fix test

fix test

Fix sqlite dump

Fix sqlite dump

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1639
2020-07-09 01:41:12 +00:00
tmalaher 55594d1dbe Oracle uses double quotes for quoting table/column/etc. names (#1674)
Oracle uses doulbe quotes for quoting table/column/etc. names

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1674
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-05-08 12:13:13 +00:00
daxiong 3bb787a2f7 fix GetColumns missing ordinal position (#1660)
fix GetColumns missing  ordinal position

Co-authored-by: zhubo <816078@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1660
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-04-23 12:57:44 +00:00
Lunny Xiao 79bdda3cf1 Move all integrations tests to a standalone sub package (#1635)
Fix vet

Remove unused files

Move all integrations tests to a standalone sub package

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1635
2020-03-27 07:13:04 +00:00
Lunny Xiao 6254e7899f Move column string to standalone method (#1633)
Move column string to standalone method

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1633
2020-03-26 12:01:28 +00:00
Lunny Xiao 0a3685be83 Fix postgres schema problem (#1624)
Fix postgres

Add DefaultPostgresSchema back

force push

Fix postgres schema problem

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1624
2020-03-25 09:36:45 +00:00
Lunny Xiao 5053c35701 Don't keep db on dialects (#1623)
don't keep db on dialects

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1623
2020-03-24 02:19:24 +00:00
tomoyamachi 2ece3bacbb Oracle : Local Naming Method (#1515)
go mod tidy

stop using xorm.io/core

Merge branch 'master' into fix-oracle-db

revert a goracle parser function

add TestParseOracleConnStr

Oracle : Local Naming Method

Co-authored-by: Tomoya AMACHI <tomoya.amachi@gmail.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1515
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-23 02:03:04 +00:00
Lunny Xiao a7a1dc5c42 Fix setschema (#1606)
Fix schema

Fix setschema

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1606
2020-03-17 06:50:06 +00:00
Lunny Xiao b7b2b21a40 Fix dump/import bug (#1603)
Fix bug

Fix mssql

Fix postgres

Fix import test

Fix dump/import bug

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1603
2020-03-15 02:02:37 +00:00
Lunny Xiao 537d82a6f7 Ignore schema when dbtype is not postgres (#1593)
Ignore schema when dbtype is not postgres

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1593
2020-03-10 13:15:18 +00:00
Jerry 2f95c750c3 jerry:add postgre data_type array (#1589)
fix err,add postgres column ARRAY

fix err,add postgres column ARRAY

Co-authored-by: Jerry <85411418@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1589
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-03-10 06:11:42 +00:00
Lunny Xiao 9d4594632f Fix mssql issue with duplicate columns. (#1225)
fix test

fix test

Fix mssql issue with duplicate columns.

The `GetColumns()` method for the mssql dialect can return the same
column multiple times if the column is in multiple indexes.

Co-authored-by: Robert G. Jakabosky <bobby@sharedrealm.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/1225
2020-03-10 04:46:46 +00:00
Lunny Xiao 4ef030c9cc mysql8.0 中同步数据前,获取数据库结构,因tableRaw为空导致同步失败 (#808)
mysql8.0 中同步数据前,获取数据库结构,因tableRaw为空导致同步失败

Co-authored-by: 崔彦鹏 <mohong122@qq.com>
Reviewed-on: https://gitea.com/xorm/xorm/pulls/808
2020-03-09 06:37:03 +00:00
Lunny Xiao 3617ee736f Only replace quotes when necessary (#1584)
fix test

improve code

improve code

improve code

improve code

Fix replace quote

fix test

Only replace quotes when necessary

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1584
2020-03-09 02:17:37 +00:00
Lunny Xiao 257653726e return sqls for create table (#1580)
return sqls for create table

Reviewed-on: https://gitea.com/xorm/xorm/pulls/1580
2020-03-07 12:06:28 +00:00