Commit Graph

431 Commits

Author SHA1 Message Date
Jinzhu 9635d25150 Fix query with uninitialized map 2021-11-01 13:00:52 +08:00
Jinzhu 9f533950a2 Add dest value if current size equal zero 2021-10-28 17:12:31 +08:00
Jinzhu e953880d19 Add returning tests 2021-10-28 09:17:33 +08:00
Jinzhu 835d7bde59 Add returning support to delete 2021-10-28 07:56:55 +08:00
Jinzhu af3fbdc2fc Improve returning support 2021-10-26 22:40:14 +08:00
Jason Lee d3211908a0
Refactor ParseWithSchemaTable method and improve test. (#4789)
* Refactor ParseWithSchemaTable method and improve test.

* Fix schema.ParseWithSchemaTable method for only use schemaTable in migrator and improve test.

* Rename `schemaTable` to `specialTableName` for clearly argument.
2021-10-25 11:26:44 +08:00
Wendell Sun a3bd9c3ea2 fix: automigrate error caused by indexes while using dynamic table name 2021-10-19 09:59:57 +08:00
Jim 19cf645dbd feat: Convert SQL nulls to zero values (ConvertNullToZeroValues)
Makes it the default behavior to convert SQL null values to zero
values for model fields which are not pointers.
2021-10-13 08:11:22 -04:00
kinggo 696092e287
update tests' go.mod and tests_all.sh (#4774) 2021-10-13 14:41:33 +08:00
kinggo ec58e3319f
fixed:panic when create value from nil struct pointer. (#4771)
* fixed:create nil pointer

* fixed:panic when create value from nil struct pointer.
2021-10-12 21:19:08 +08:00
kinggo 418c60c83c
fixed: clauseSelect.Columns missed when use Join And execute multiple query. (#4757) 2021-10-09 16:55:45 +08:00
Jinzhu d4c838c1ce Upgrade sqlite driver 2021-10-08 17:31:58 +08:00
kinggo b46e2afc4a
fix : update miss where's condition when primary key use "<-:create" tag (#4738)
* fix:update miss where condition

* fix:rename test case
2021-10-08 13:47:01 +08:00
dependabot[bot] 57d927d046
Bump gorm.io/driver/postgres from 1.1.1 to 1.1.2 in /tests (#4740)
Bumps [gorm.io/driver/postgres](https://github.com/go-gorm/postgres) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/go-gorm/postgres/releases)
- [Commits](https://github.com/go-gorm/postgres/compare/v1.1.1...v1.1.2)

---
updated-dependencies:
- dependency-name: gorm.io/driver/postgres
  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>
2021-10-08 10:54:50 +08:00
Jinzhu 002bf78ea7 Fix Join condition with DB, close #4719 2021-09-28 21:43:31 +08:00
kinggo 6864a24150
fix:remove the tableName judgment in pluck (#4731) 2021-09-27 22:11:29 +08:00
dependabot[bot] 199c8529b6
Bump gorm.io/driver/postgres from 1.1.0 to 1.1.1 in /tests (#4699)
Bumps [gorm.io/driver/postgres](https://github.com/go-gorm/postgres) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/go-gorm/postgres/releases)
- [Commits](https://github.com/go-gorm/postgres/compare/v1.1.0...v1.1.1)

---
updated-dependencies:
- dependency-name: gorm.io/driver/postgres
  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>
2021-09-20 21:33:38 +08:00
dependabot[bot] d67120a155
Bump gorm.io/driver/sqlite from 1.1.4 to 1.1.5 in /tests (#4701)
Bumps [gorm.io/driver/sqlite](https://github.com/go-gorm/sqlite) from 1.1.4 to 1.1.5.
- [Release notes](https://github.com/go-gorm/sqlite/releases)
- [Commits](https://github.com/go-gorm/sqlite/compare/v1.1.4...v1.1.5)

---
updated-dependencies:
- dependency-name: gorm.io/driver/sqlite
  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>
2021-09-20 21:25:29 +08:00
Jinzhu ab355336cb Fix scan with interface 2021-09-17 18:35:14 +08:00
Jinzhu da16a8aac6 Update updated_at when upserting with Create OnConflict 2021-09-17 15:29:49 +08:00
Jinzhu 12bbde89e6 Fix Scan with interface 2021-09-17 14:04:19 +08:00
Jinzhu 61b018cb94 Fix count with selected * 2021-09-16 11:17:54 +08:00
Jinzhu 04f049c1da Add tests for RowsAffected 2021-09-09 11:22:55 +08:00
Jinzhu a16db07945 Refactor Join ON 2021-09-07 21:21:44 +08:00
Jinzhu ba16b2368f
Refactor update record (#4679) 2021-09-07 20:04:54 +08:00
Jinzhu 3b6a7c8aec Update sqlserver driver 2021-09-07 12:01:19 +08:00
Adrien Carreira d047f854e6 PR Comments 2021-09-06 20:13:20 +08:00
Adrien Carreira 52cc438d07 JoinsOn unit test + use all primary keys 2021-09-06 20:13:20 +08:00
riverchu 4581e8b590 test: update Save test 2021-09-06 20:13:20 +08:00
riverchu c898622791 test: add testcase in TestSave 2021-09-06 20:13:20 +08:00
dependabot[bot] a89d4d8fd5
Bump github.com/lib/pq from 1.10.2 to 1.10.3 in /tests (#4676)
Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.10.2 to 1.10.3.
- [Release notes](https://github.com/lib/pq/releases)
- [Commits](https://github.com/lib/pq/compare/v1.10.2...v1.10.3)

---
updated-dependencies:
- dependency-name: github.com/lib/pq
  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>
2021-09-06 16:26:14 +08:00
dependabot[bot] 5f019f74bf
Bump gorm.io/gorm from 1.21.13 to 1.21.14 in /tests (#4655)
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.21.13 to 1.21.14.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.21.13...v1.21.14)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  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>
2021-09-03 17:47:50 +08:00
zkqiang 74746211b8 Test update association with non-updatable 2021-08-26 13:37:49 +08:00
dependabot[bot] 0934b10856
Bump gorm.io/driver/sqlserver from 1.0.7 to 1.0.8 in /tests (#4631)
Bumps [gorm.io/driver/sqlserver](https://github.com/go-gorm/sqlserver) from 1.0.7 to 1.0.8.
- [Release notes](https://github.com/go-gorm/sqlserver/releases)
- [Commits](https://github.com/go-gorm/sqlserver/compare/v1.0.7...v1.0.8)

---
updated-dependencies:
- dependency-name: gorm.io/driver/sqlserver
  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>
2021-08-23 15:30:02 +08:00
Sec Cake 093694fbf2
Fix extra 'AND' when len(values) == 0 ON IN.NegationBuild() (#4618) 2021-08-20 18:06:48 +08:00
dependabot[bot] 7a53d8e46b
Bump gorm.io/driver/mysql from 1.1.1 to 1.1.2 in /tests (#4615)
Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/go-gorm/mysql/releases)
- [Commits](https://github.com/go-gorm/mysql/compare/v1.1.1...v1.1.2)

---
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>
2021-08-20 17:52:56 +08:00
dependabot[bot] e076e9e0fb
Bump gorm.io/gorm from 1.21.12 to 1.21.13 in /tests (#4616)
Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.21.12 to 1.21.13.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.21.12...v1.21.13)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  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>
2021-08-20 17:52:48 +08:00
SmallTianTian 82fe815303
fix: table couln't be reentrant (#4556) 2021-08-09 13:20:22 +08:00
Matthieu MOREL cbe72751ac
Update Dependencies (#4582)
* Create dependabot.yml

* Bump reviewdog/action-golangci-lint from 1 to 2 (#1)

Bumps [reviewdog/action-golangci-lint](https://github.com/reviewdog/action-golangci-lint) from 1 to 2.
- [Release notes](https://github.com/reviewdog/action-golangci-lint/releases)
- [Commits](https://github.com/reviewdog/action-golangci-lint/compare/v1...v2)

---
updated-dependencies:
- dependency-name: reviewdog/action-golangci-lint
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump actions/stale from 3.0.7 to 4 (#2)

Bumps [actions/stale](https://github.com/actions/stale) from 3.0.7 to 4.
- [Release notes](https://github.com/actions/stale/releases)
- [Changelog](https://github.com/actions/stale/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/stale/compare/v3.0.7...v4)

---
updated-dependencies:
- dependency-name: actions/stale
  dependency-type: direct:production
  update-type: version-update:semver-major
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump gorm.io/gorm from 1.21.9 to 1.21.12 in /tests (#3)

Bumps [gorm.io/gorm](https://github.com/go-gorm/gorm) from 1.21.9 to 1.21.12.
- [Release notes](https://github.com/go-gorm/gorm/releases)
- [Commits](https://github.com/go-gorm/gorm/compare/v1.21.9...v1.21.12)

---
updated-dependencies:
- dependency-name: gorm.io/gorm
  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>

* Bump gorm.io/driver/mysql from 1.0.5 to 1.1.1 in /tests (#4)

Bumps [gorm.io/driver/mysql](https://github.com/go-gorm/mysql) from 1.0.5 to 1.1.1.
- [Release notes](https://github.com/go-gorm/mysql/releases)
- [Commits](https://github.com/go-gorm/mysql/compare/v1.0.5...v1.1.1)

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

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/lib/pq from 1.6.0 to 1.10.2 in /tests (#5)

Bumps [github.com/lib/pq](https://github.com/lib/pq) from 1.6.0 to 1.10.2.
- [Release notes](https://github.com/lib/pq/releases)
- [Commits](https://github.com/lib/pq/compare/v1.6.0...v1.10.2)

---
updated-dependencies:
- dependency-name: github.com/lib/pq
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump github.com/google/uuid from 1.2.0 to 1.3.0 in /tests (#6)

Bumps [github.com/google/uuid](https://github.com/google/uuid) from 1.2.0 to 1.3.0.
- [Release notes](https://github.com/google/uuid/releases)
- [Commits](https://github.com/google/uuid/compare/v1.2.0...v1.3.0)

---
updated-dependencies:
- dependency-name: github.com/google/uuid
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

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

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-09 13:16:25 +08:00
Walter Scheper a870486c4f
Do not emit ORDER BY for empty values (#4592)
This restores the behavior from gorm v1, where calling `DB.Order` with
an empty string, nil, or any unexpected type is a no-op.
2021-08-09 13:14:23 +08:00
s-takehana 2202e99cbf
Fix create index with comments in MySQL (#4521)
* Fix create index with comments in MySQL

* Fix tests
2021-07-18 11:47:44 +08:00
Jinzhu b616d810eb Fix scan single value to custom type, close #4501 2021-07-13 19:29:10 +08:00
Jinzhu 2ec7043818 Respect update permission for OnConflict Create 2021-07-13 18:04:42 +08:00
Jinzhu 8e67a08774 Fix Scopes with Row, close #4465 2021-06-18 15:38:20 +08:00
Jinzhu 5b65b02805 Update tests go.mod 2021-06-11 16:00:26 +08:00
Jinzhu e425ed6f6a Update tests go.mod 2021-06-10 20:26:21 +08:00
Ikko Ashimine bcf2b385a4
Fix typo in associations_test.go (#4407)
occured -> occurred
2021-05-27 17:40:28 +08:00
Jinzhu 92c3ba9dcc Fix create new db sessions in scopes 2021-05-17 15:36:07 +08:00
Jinzhu 6b7abc54a2 Fix tests 2021-05-06 13:06:31 +08:00
Jinzhu d483ffa45c Fix Preload with nil pointer 2021-04-15 10:37:05 +08:00
Jinzhu 33601dc72f Support Having w/o Group 2021-03-30 18:28:09 +08:00
Jinzhu 26e0c6fb69 skip test sqlserver due to it will raise data race for invalid sql 2021-03-24 17:12:30 +08:00
Jinzhu 8204d0ada2 Update tests script 2021-03-24 16:44:51 +08:00
Jinzhu 704e53a774 Call scopes before parse model value, close #4209 2021-03-24 16:35:39 +08:00
Jinzhu 4d5cec8bdd Add golang 1.16 2021-03-24 14:22:36 +08:00
Genta Kamitani 26dd4c980a
Fix: FindInBatches ignores errors (#4203) 2021-03-22 14:11:07 +08:00
Jinzhu 8c92d9694a Fix to call Scopes with using Migrator 2021-03-19 16:34:51 +08:00
Jinzhu 2055e29eb8 Refactor nested preload all associations 2021-03-14 10:42:58 +08:00
Jinzhu 912360097a Fix Scopes with Migrator, close #4145 2021-03-11 10:36:14 +08:00
Ratan Phayade a3abb5fedf
support named params in Select API (#4142)
* adds support for named arguments in select

* changes clause identifies and adds test
2021-03-07 10:59:00 +08:00
Jinzhu a948c84607 Revert "Revert "Don't override the from clauses, close #4129" close #4139"
This reverts commit d6c23586ae.
2021-03-05 22:19:34 +08:00
Jinzhu d6c23586ae Revert "Don't override the from clauses, close #4129" close #4139
This reverts commit 664755270d.
2021-03-05 19:42:54 +08:00
Jinzhu 664755270d Don't override the from clauses, close #4129 2021-03-04 19:16:08 +08:00
Jinzhu eb9a704fda Fix update UpdatedAt when full saving associations, close #4115 2021-02-26 17:11:25 +08:00
Jinzhu 189547f615 Fix new session with Begin, close #4120 2021-02-26 16:43:43 +08:00
Jinzhu 73d44a4f97 Fix create duplicated constraint, close #4090 2021-02-16 08:52:56 +08:00
Jinzhu 84ea3ec0cc Fix sub query argument order with multiple raw SQL 2021-02-09 19:56:45 +08:00
Jinzhu df24821896 Fix SubQuery for raw sql 2021-02-09 17:05:50 +08:00
yrong1997 2ba612e805
Add field tag to ignore migration (#4028)
* Add field tag to ignore migration

* Fix null value with space

* refactor migration tag
2021-02-09 16:03:02 +08:00
Jinzhu 883c32e59a Support Unscoped when delete with selected associations, close #4062 2021-02-07 14:36:27 +08:00
Jinzhu 4373aa01ab Don't call AfterFind hooks if no record found, close #4048 2021-02-07 12:44:59 +08:00
Jinzhu 3d3208ed60 initialize config plugins 2021-02-03 16:27:49 +08:00
Jinzhu 8500380e60 Add name checker test, close #4007 2021-01-27 17:45:59 +08:00
rorschach ba59065024 retrieving gorm object support pointer 2021-01-27 11:48:47 +08:00
Jinzhu 08678106a4 Support replace associations without the creation in association mode, close #3937 2021-01-26 14:34:21 +08:00
Jinzhu 916338a9e1 Test migrate constraints, close #3986 2021-01-26 13:39:34 +08:00
Jinzhu 35ebfe6874 Support group conditions with single OR condition 2021-01-20 18:24:05 +08:00
Jinzhu de850edb4f Fix Change UpdatedAt to current time when doing OnConflict UpdateAll 2021-01-11 19:16:47 +08:00
Jinzhu fe553a7c1a Fix prepared statement in transaction mode can't be shared in normal operations, close #3927 2021-01-10 16:46:06 +08:00
Jinzhu 7302c8a136 Fix tests and logger 2021-01-10 15:27:53 +08:00
Jinzhu d888c799d7 Change UpdatedAt to current time when doing OnConflict UpdateAll 2021-01-08 19:20:42 +08:00
Jinzhu 1b8cb07cf2 Allow Where select fields when searching with struct 2020-12-30 18:13:52 +08:00
Jinzhu ade0bd6d60 Fix SELECT with sql expression in some cases, close #3889 2020-12-28 10:40:30 +08:00
Jinzhu ad8a5c0d1a Add QueryFields mode when query many2many relations 2020-12-25 16:35:25 +08:00
Jinzhu 468152d45b Add DisableNestedTransaction support 2020-12-16 19:33:35 +08:00
Jinzhu 6848ae872f Fix gorm.Expr with SubQuery, fix #3857 2020-12-15 15:50:35 +08:00
Jinzhu 0f00493c50 Continue to update tracking fields even not selected with Select, but skip them if omited with Omit, fix #3856 2020-12-15 11:18:29 +08:00
Jinzhu 14a0976dd4 populate the DeletedAt field when soft delete, fix #3855 2020-12-15 10:39:20 +08:00
Jinzhu e1952924e2 Support named Joins, close #3833 2020-12-07 10:31:06 +08:00
Jinzhu 1ef1f0bfe4 Fix Count with complicated Select, close #3826 2020-12-06 14:30:42 +08:00
Jinzhu 0c12a4c360 Add CreateBatchSize option 2020-12-02 14:59:50 +08:00
Jinzhu 6950007d6a Fix failed to parse relations when using goroutinue, close #3790
commit ee0ec43e8dfa85c1c1a562c2d0d47776cf8abd92
Author: Jinzhu <wosmvp@gmail.com>
Date:   Fri Nov 27 14:31:57 2020 +0800

    Fix failed to parse relations when using goroutinue, close #3790

commit 590e73ff95
Author: rokeyzhao <rokeyzhao@tencent.com>
Date:   Thu Nov 26 20:27:55 2020 +0800

    test: no cache preload in goroutine
2020-11-27 14:32:20 +08:00
Luis Guillermo Gómez 47ffd0bef4
Select all fields in SQL queries avoiding the SELECT * FROM (#3731)
* Select all fields in SQL queries avoiding the SELECT * FROM

* Select table name with fields in SQL queries

* Use QueryFields to execute the SQL query with all fields of the table
2020-11-20 15:38:25 +08:00
Deviller d66af581b4
Fix Association.Replace() error returning (#3766)
* Fix Association.Replace() error returning

* Fallback to gorm.Model at TestAssociationNotNullClear()
2020-11-19 19:24:34 +08:00
Jinzhu 54b80b18bc Allow to omit fields in associations, close #3752 2020-11-17 21:49:40 +08:00
Jinzhu 50df9da6a1 Allow to skip associations when creating join table for many2many, close #3605 2020-11-17 20:24:08 +08:00
Jinzhu 26504f5cae Use NewDB to replace WithConditions for Session 2020-11-17 16:28:37 +08:00
Jinzhu f6e1786ca2 Add skip hooks support 2020-11-17 15:19:58 +08:00
Jinzhu f5c2126c29 Fix FindInBatches tests 2020-11-17 13:14:34 +08:00
Jinzhu 320f33061c Fix FindInBatches to modify the query conditions, close #3734 2020-11-17 11:19:04 +08:00