Commit Graph

588 Commits

Author SHA1 Message Date
Cr f0360dccbf
fix: embedded should be nil if not exists (#6219) 2023-04-11 10:13:25 +08:00
Saeid Kanishka b444011d09
refactor: translatorError flag added for backward compatibility (#6178)
Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com>
2023-03-24 10:07:05 +08:00
black-06 1a7ea98ac5
fix: count with group (#6157) (#6160)
* fix: count with group (#6157)

* add an easy-to-understand ut
2023-03-23 11:19:53 +08:00
black-06 0c7e575f19
save should be idempotent #6139 (#6149) 2023-03-23 11:18:57 +08:00
Jinzhu cc2d46e5be reuse name for savepoints from nested transaction, close #6060 2023-03-10 17:42:38 +08:00
Cr 8bf1f269cf
feat: support nested join (#6067)
* feat: support nested join

* fix: empty rel value
2023-03-10 17:21:56 +08:00
Jeffry Luqman 654b5f2006
test: pgsql alter column from smallint or string to boolean (#6107)
* test: pgsql alter column from smallint to boolean

* test: pgsql alter column from string to boolean
2023-03-10 17:11:56 +08:00
Cr b62192456f
fix: diff schema update assign value (#6096) 2023-03-10 17:04:54 +08:00
Truong Nguyen ed474152b1
Fix: Composite primary key with auto-increment value returns 0 after insert (#6127)
* Fix #4930 workaround for databases that support auto-increment in composite primary key.

* Add test for composite key with auto-increment.

* schema.go: use field.AutoIncrement instead of field.TagSettings["AUTOINCREMENT"], add test to check autoincrement:false

create_test.go: remove unused code: drop table CompositeKeyProduct

---------

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2023-03-10 16:50:03 +08:00
Jinzhu 1643a36260 Fix possible concurrency problem for serializer 2023-03-10 16:39:57 +08:00
Cr e9f25c73ee
fix: on confilct with default null (#6129)
* fix: on confilct with default null

* Update create.go

---------

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2023-03-10 16:35:26 +08:00
Saeid Kanishka 85eaf9eeda
feat: Unique Constraint Violation error translator for different drivers (#6004)
* feat: duplicated key error translator for different drivers

* test: removed the dependency

* test: fixed broken tests

* refactor: added ErrorTransltor interface

* style: applied styler

---------

Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com>
2023-03-06 14:03:31 +08:00
Jinzhu f3874339ef Fix Save with stress tests 2023-03-02 17:22:51 +08:00
Jiepeng Cao 877cc9148f
Remove redundant code (#6087) 2023-02-27 15:44:35 +08:00
black-06 a80707de9e
Create and drop view (#6097)
* create view

* add comment

* fix test

* check param and add comment
2023-02-27 15:43:10 +08:00
Jiepeng Cao 391c961c7f
quotes on docker-compose.yml ports (#6089) 2023-02-27 15:39:02 +08:00
Cr 04cbd956eb
test: pgsql migrate unique index (#6028) 2023-02-18 09:21:07 +08:00
black-06 e66a059b82
fix: update panic if model is not ptr (#6037)
* fix: update panic if model is not ptr

* fix: update panic if model is not ptr

* fix: update panic if model is not ptr

* fix: raise an error if the value is not addressable

* fix: return
2023-02-18 09:20:29 +08:00
black-06 42fc75cb2c
fix: association concurrently appending (#6044)
* fix: association concurrently appending

* fix: fix unit test

* fix: fix gofumpt
2023-02-18 09:19:24 +08:00
Michael Anstis 532e9cf4cc
Issue 6054: Unscoped not working with PreLoad on Joins (#6058)
* Issue 6054: Unscoped not working with PreLoad on Joins

* Formatting

---------

Co-authored-by: Michael Anstis <manstis@redhat.com>
2023-02-18 09:06:43 +08:00
Cheese 02b7e26f6b
feat: add tidb integration test cases (#6014)
* feat: support tidb integration test

* feat: update the mysql driver version to test
2023-02-08 16:29:09 +08:00
Cr 878ac51e98
fix:throw model value required error (#6031)
* fix:throw model value required error

* chore:ingore typecheck

* chore:ingore errcheck

* refactor: use other error

* chore: gofumpt style
2023-02-08 13:40:41 +08:00
qiankunli cfbcedbf03
fix: support zeroValue tag on DeletedAt (#6011)
* fix: support zeroValue tag on DeletedAt

Signed-off-by: qiankunli <qiankun.li@qq.com>

* Update soft_delete_test.go

* Update tests_test.go

* Update soft_delete.go

---------

Signed-off-by: qiankunli <qiankun.li@qq.com>
Co-authored-by: Jinzhu <wosmvp@gmail.com>
2023-02-01 14:40:55 +08:00
Jinzhu d834dd60b7 Remove unnecessary code 2023-01-19 15:22:13 +08:00
Jinzhu 3d35ddba55 Fix use table.* as select/omit columns 2023-01-12 16:52:56 +08:00
Jinzhu 2bc913787b support implicit table alias, close #5840 #5940 2023-01-02 21:46:27 +08:00
Jinzhu 3d91802b1d Fix unexpected alter table in auto migration, close #5942, #5943 2023-01-02 21:06:04 +08:00
Jinzhu 4b768c8aff Upgrade tests deps 2023-01-01 22:22:08 +08:00
Haibo 16a272209a
fix(migrator): Tag default:'null' always causes field migration #5953 (#5954)
* fix(migrator): Tag default:'null' always causes field migration #5953

* Update migrate_test.go

* Update migrate_test.go

* Update migrate_test.go

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2023-01-01 22:14:28 +08:00
Haibo da2b2861de
fix(migrator): ignore relationships when migrating #5913 (#5946) 2023-01-01 19:54:28 +08:00
Jinzhu ddd3cc2502 Add ParameterizedQueries option support for logger, close #5288 2022-12-25 11:37:23 +08:00
Cr 794edad60e
test(MigrateColumn): mock alter column to improve field compare (#5499)
* test(MigrateColumn): mock alter column to improve field compare

* Update migrate_test.go

* Update migrate_test.go

* Update migrate_test.go

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2022-12-24 17:42:16 +08:00
Cr 1935eb0adb
feat: support inner join (#5583)
* feat: support inner join

* test: mixed inner join and left join

* chore: code comment

* Update statement.go

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2022-12-24 12:27:38 +08:00
Ning bbd2bbe521
fix:Issue migrating field with CURRENT_TIMESTAMP (#5906)
Co-authored-by: ningfei <accelerator314@outlook.com>
2022-12-24 11:02:11 +08:00
Edward McFarlane 4ec73c9bf4
Add test case for embedded value selects (#5901)
* Add test case for embedded value selects

* Revert recycle struct optimisation to avoid pointer overwrites
2022-12-19 11:49:05 +08:00
Cr d9525d4da4
fix: skip append relation field to default db value (#5885)
* fix: relation field returning

* chore: gofumpt style
2022-12-01 20:26:59 +08:00
Jinzhu f91313436a Fix group by with count logic 2022-11-21 11:10:56 +08:00
Cr 342310fba4
fix(FindInBatches): throw err if pk not exists (#5868) 2022-11-21 10:49:27 +08:00
Cr b2f42528a4
fix(Joins): args with select and omit (#5790)
* fix(Joins): args with select and omit

* chore: gofumpt style
2022-11-02 10:28:00 +08:00
Cr 9d82aa5673
test: invalid cache plan with prepare stmt (#5778)
* test: invalid cache plan with prepare stmt

* test: more test cases

* test: drop and rename column
2022-10-20 14:10:47 +08:00
Cr 5dd2bb4827
feat(PreparedStmtDB): support reset (#5782)
* feat(PreparedStmtDB): support reset

* fix: close all stmt

* test: fix test

* fix: delete one by one
2022-10-19 14:46:59 +08:00
Jinzhu 3f20a543fa Support use clause.Interface as query params 2022-10-18 18:01:55 +08:00
viatoriche / Maxim Panfilov 62593cfad0 add test: TestAutoMigrateInt8PG: shouldn't execute ALTER COLUMN TYPE smallint, close #5762 2022-10-18 17:28:06 +08:00
Jinzhu a0f4d3f7d2 Save as empty string for not nullable nil field serialized into json 2022-10-18 16:25:39 +08:00
Jinzhu ab5f80a8d8 Save as NULL for nil object serialized into json 2022-10-18 15:44:56 +08:00
Cr 186e8a9e14
fix: association without pks (#5779) 2022-10-18 11:58:42 +08:00
Jinzhu 2a788fb20c Upgrade tests go.mod 2022-10-17 17:01:42 +08:00
Jinzhu 2c56954cb1 tests mariadb with returning support 2022-10-08 20:48:22 +08:00
Jinzhu e93dc3426e Test postgres autoincrement check 2022-10-08 17:16:32 +08:00
Jinzhu 983e96f142 Add tests for alter column type 2022-10-08 16:04:57 +08:00
Jinzhu 34fbe84580 Add TableName with NamingStrategy support, close #5726 2022-10-07 21:18:37 +08:00
Wen Sun 9564b82975
Fix OnConstraint builder (#5738) 2022-10-07 13:46:20 +08:00
Cr 0b7113b618
fix: prepare deadlock (#5568)
* fix: prepare deadlock

* chore[ci skip]: code style

* chore[ci skip]: test remove unnecessary params

* fix: prepare deadlock

* fix: double check prepare

* test: more goroutines

* chore[ci skip]: improve code comments

Co-authored-by: Jinzhu <wosmvp@gmail.com>
2022-09-30 18:13:36 +08:00
Stephano George a3cc6c6088 Fix: wrong value when Find with Join with same column name, close #5723, #5711 2022-09-30 17:18:42 +08:00
jesse.tang be440e7512
fix possible nil panic in tests (#5720)
* fix maybe nil panic

* reset code
2022-09-30 11:14:34 +08:00
Nguyen Huu Tuan 328f301982
add some test case which related the logic (#5477) 2022-09-22 18:35:21 +08:00
kinggo 12237454ed fix: use preparestmt in trasaction will use new conn, close #5508 2022-09-22 16:47:43 +08:00
Cr 101a7c789f
fix: scan array (#5624)
Co-authored-by: Jinzhu <wosmvp@gmail.com>
2022-09-22 15:51:47 +08:00
Jinzhu 3a72ba102e Allow shared foreign key for many2many jointable 2022-09-22 15:03:41 +08:00
Cr 5ed7b1a65e
fix: same embedded filed name (#5705) 2022-09-22 11:25:03 +08:00
Jiepeng Cao b3eb1c8c51
simplified regexp (#5677) 2022-09-05 15:39:19 +08:00
Cr d71caef7d9
fix: remove uuid autoincrement (#5620) 2022-09-03 20:00:21 +08:00
Shunsuke Otani 8c3018b96a
Replace `ioutil.Discard` with `io.Discard` (#5603) 2022-08-15 10:50:06 +08:00
hjwblog.com 6e03b97e26
fix: empty serilizer err #5524 (#5525)
* fix: empty serilizer err #5524

* feat: fix UnixSecondSerializer return nil

* feat: split type case

Co-authored-by: huanjiawei <huanjiawei@bytedance.com>
2022-07-27 13:59:47 +08:00
Cr 06e174e24d
fix: embedded default value (#5540) 2022-07-25 14:10:30 +08:00
Jinzhu 75720099b5 Create a new db in FindInBatches 2022-07-18 18:07:05 +08:00
Goxiaoy 2ba599e8b7
fix empty QueryClauses in association (#5502) (#5503)
* fix empty QueryClauses in association (#5502)

* test: empty QueryClauses in association (#5502)

* style: empty QueryClauses in association (#5502)

* style: empty QueryClauses in association (#5502)
2022-07-15 11:15:18 +08:00
Jinzhu 4d40e34734 Update select tests 2022-07-14 14:55:54 +08:00
Jinzhu 62fdc2bb3b Fix serializer with empty string 2022-07-11 11:51:05 +08:00
Jinzhu fe01e1b9f4 Fix Model with slice data 2022-07-07 14:43:33 +08:00
Cr 46bce170ca
test: pg array type (#5480) 2022-07-04 16:42:27 +08:00
Cr c74bc57add
fix: association many2many duplicate elem (#5473)
* fix: association many2many duplicate elem

* chore: gofumpt style
2022-07-01 15:12:15 +08:00
Cr 235c093bb9
fix(MigrateColumn):declared different type without length (#5465) 2022-06-29 10:07:42 +08:00
wws 3e6ab99043
fix:serializer contain field panic (#5461) 2022-06-25 16:32:47 +08:00
Cr 8d45714628
fix: reset null value in slice (#5417)
* fix: reset null value in slice

* fix: can not set field in-place in join
2022-06-14 13:48:50 +08:00
Bexanderthebex d01de7232b
enhancement: Avoid calling reflect.New() when passing in slice of values to `Scan()` (#5388)
* fix: reduce allocations when slice of values

* chore[test]: Add benchmark for scan

* chore[test]: add bench for scan slice

* chore[test]: add bench for slice pointer and improve tests

* chore[test]: make sure database is empty when doing slice tests

* fix[test]: correct sql delete statement

* enhancement: skip new if rows affected = 0
2022-06-01 11:50:57 +08:00
dependabot[bot] f4e9904b02
chore(deps): bump gorm.io/driver/mysql from 1.3.3 to 1.3.4 in /tests (#5385)
Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.3.3 to 1.3.4.
- [Release notes](https://github.com/go-gorm/mysql/releases)
- [Commits](https://github.com/go-gorm/mysql/compare/v1.3.3...v1.3.4)

---
updated-dependencies:
- dependency-name: gorm.io/driver/mysql
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-06-01 10:26:09 +08:00
Cr 93986de8e4
fix: migrate column default value (#5359)
Co-authored-by: Jinzhu <wosmvp@gmail.com>
2022-05-28 23:09:13 +08:00
t-inagaki@hum_op dc1ae394f3
fixed FirstOrCreate not handled error when table is not exists (#5367)
* fixed FirstOrCreate not handled error when table is not exists

* delete useless part
2022-05-28 22:18:43 +08:00
Cr 7e13b03bd4
fix: duplicate column scan (#5369)
* fix: duplicate column scan

* fix: dup filed in inconsistent schema and database

* chore[ci skip]: gofumpt style

* chore[ci skip]: fix typo
2022-05-28 22:18:07 +08:00
Cr 7d1a92d60e
test: test for skip prepared when auto migrate (#5350) 2022-05-22 16:12:28 +08:00
Cr 7496c3a56e
fix: trx in hooks clone stmt (#5338)
* fix: trx in hooks

* chore: format by gofumpt
2022-05-17 14:13:41 +08:00
black-06 f5e77aab2f
fix: quote index when creating table (#5331) 2022-05-17 10:59:53 +08:00
Cr 373bcf7aca
fix: many2many auto migrate (#5322)
* fix: many2many auto migrate

* fix: uuid ossp
2022-05-09 10:07:18 +08:00
Cr 19b8d37ae8
fix: preload with skip hooks (#5310) 2022-05-04 18:57:53 +08:00
Cr b0104943ed
fix: callbcak sort when using multiple plugin (#5304) 2022-04-30 09:57:16 +08:00
Heliner d3488ae6bc
fix: add judge result of auto_migrate (#5306)
Co-authored-by: fredhan <fredhan@futunn.com>
2022-04-30 09:50:53 +08:00
Cr bd7e42ec65
fix: AutoMigrate with special table name (#5301)
* fix: AutoMigrate with special table name

* test: migrate with special table name
2022-04-27 21:13:48 +08:00
Jinzhu 6a6dfdae72 Refactor FirstOrCreate, FirstOrInit 2022-04-26 17:16:48 +08:00
Cr a0cc631272
test: test for postgrs serial column (#5234)
* test: test for postgrs sercial column

* test: only for postgres

* chore: spelling mistake

* test: for drop sequence
2022-04-24 12:13:27 +08:00
Cr 9b80fe9e96
fix: stmt.Changed zero value filed behavior (#5281)
* fix: stmt.Changed zero value filed behavior

* chore: rename var
2022-04-24 09:08:52 +08:00
Jinzhu 88c26b62ee Support Scopes in group conditions 2022-04-20 17:21:38 +08:00
Cr b49ae84780
fix: FindInBatches with offset limit (#5255)
* fix: FindInBatches with offset limit

* fix: break first

* fix: FindInBatches Limit zero
2022-04-17 09:58:33 +08:00
Jinzhu d421c67ef5 Remove ErrRecordNotFound error from log when using Save 2022-04-14 10:51:39 +08:00
Cr a65912c588
fix: FirstOrCreate RowsAffected (#5250) 2022-04-13 15:52:07 +08:00
Filippo Del Moro 6aa6d37fc4
Fix scanIntoStruct (#5241)
* Reproduces error case

* Fix scanIntoStruct

Co-authored-by: Filippo Del Moro <filippo.delmoro@facile.it>
2022-04-13 15:47:04 +08:00
Jinzhu 74e07b049c Serializer unixtime support ptr of int 2022-04-11 22:07:56 +08:00
Jinzhu 41bef26f13 Remove shared sync pool for Scanner compatibility 2022-04-11 21:37:44 +08:00
Hasan 81c4024232
Offset issue resolved for scanning results back into struct (#5227) 2022-04-07 23:56:41 +08:00
Jinzhu 9144969c83 Allow to use tag to disable auto create/update time 2022-04-02 17:17:47 +08:00