* refactor: distinguish between UniqueIndex and Index
* add test
* add ParseIndex test
* modify unique to constraint
* modify unique to constraint
* fix MigrateColumnUnique
* fix test
* fix unit test
* update test mod
* add MigrateColumnUnique to Migrator interface
* fix format lint
* add comment
* go mod tidy
* revert: revert MigrateColumn
* resolve conflicts
Go 1.22 goes somewhat toward addressing the issue using reflect
MethodByName disabling linker deadcode elimination (DCE) and the
resultant large increase in binary size because the linker cannot
prune unused code because it might be reached via reflection.
Go Issue golang/go#62257 reduces the number of incidences of this
problem by leveraging a compiler assist to avoid marking functions
containing calls to MethodByName as ReflectMethods as long as the
arguments are constants.
An analysis of Uber Technologies code base however shows that a number
of transitive imports still contain calls to MethodByName with a
variable argument, including GORM.
In the case of GORM, the solution we are proposing is because the
number of possible methods is finite, we will "unroll" this. This
demonstrably shows that GORM is not longer a problem for DCE.
Before
```
% go version
go version devel go1.22-2f3458a8ce Sat Sep 16 16:26:48 2023 -0700 darwin/arm64
% go test ./... -ldflags=-dumpdep 2> >(grep -i -e '->.*<reflectmethod>')
gorm.io/gorm.(*Statement).BuildCondition -> gorm.io/gorm/schema.ParseWithSpecialTableName <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).Method <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).MethodByName <ReflectMethod>
ok gorm.io/gorm (cached)
ok gorm.io/gorm/callbacks (cached)
gorm.io/gorm/clause_test.BenchmarkComplexSelect -> gorm.io/gorm/schema.ParseWithSpecialTableName <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).Method <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).MethodByName <ReflectMethod>
? gorm.io/gorm/migrator [no test files]
ok gorm.io/gorm/clause (cached)
ok gorm.io/gorm/logger (cached)
gorm.io/gorm/schema_test.TestAdvancedDataTypeValuerAndSetter -> gorm.io/gorm/schema.ParseWithSpecialTableName <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).Method <ReflectMethod>
type:reflect.Value <UsedInIface> -> reflect.(*Value).MethodByName <ReflectMethod>
? gorm.io/gorm/utils/tests [no test files]
ok gorm.io/gorm/schema (cached)
ok gorm.io/gorm/utils (cached)
```
After
```
%go version
go version devel go1.22-2f3458a8ce Sat Sep 16 16:26:48 2023 -0700 darwin/arm64
%go test ./... -ldflags=-dumpdep 2> >(grep -i -e '->.*<reflectmethod>')
ok gorm.io/gorm (cached)
ok gorm.io/gorm/callbacks (cached)
? gorm.io/gorm/migrator [no test files]
? gorm.io/gorm/utils/tests [no test files]
ok gorm.io/gorm/clause (cached)
ok gorm.io/gorm/logger (cached)
ok gorm.io/gorm/schema (cached)
ok gorm.io/gorm/utils (cached)
```
* max identifier length changed to 63
* default maxIdentifierLength is 64
* renamed License to LICENSE (#6336)
* Added support of "Violates Foreign Key Constraint" (#6329)
* Added support of "Violates Foreign Key Constraint"
Updated the translator and added the support of "foreign key constraint violation". For this, this error type is needed here.
* changed the description of ErrForeignKeyViolated
* refactor: error translator test (#6350)
Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com>
* fix(nested transaction): SavePoint SQL Statement not support in Prepared Statements (#6220)
* test: add nested transaction and prepareStmt coexist test case
note: please test in the MySQL environment
Change-Id: I0db32adc5f74b0d443e98943d3b182236583b959
Signed-off-by: 王柳洋 <wangliuyang.520@bytedance.com>
* fix(nested transaction): SavePoint SQL Statement not support in Prepared Statements
1. SavetPoint SQL Statement not support in Prepared Statements
e.g. see mysql8.0 doc: https://dev.mysql.com/doc/refman/8.0/en/sql-prepared-statements.html
Change-Id: I082012db9b140e8ec69764c633724665cc802692
Signed-off-by: 王柳洋 <wangliuyang.520@bytedance.com>
* revert(transaction_api): remove savepoint name pool,meaningless
Change-Id: I84aa9924fc54612005a81c83d66fdf8968ee56ad
Signed-off-by: 王柳洋 <wangliuyang.520@bytedance.com>
---------
Signed-off-by: 王柳洋 <wangliuyang.520@bytedance.com>
Co-authored-by: 王柳洋 <wangliuyang.520@bytedance.com>
* fix: save with hook (#6285) (#6294)
---------
Signed-off-by: 王柳洋 <wangliuyang.520@bytedance.com>
Co-authored-by: Avinaba Bhattacharjee <avinababhattacharjee2002@gmail.com>
Co-authored-by: Muhammad Amir Ejaz <37077032+codingamir@users.noreply.github.com>
Co-authored-by: Saeid <sk.saeidee@yahoo.com>
Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com>
Co-authored-by: wangliuyang <54885906+wangliuyang520@users.noreply.github.com>
Co-authored-by: 王柳洋 <wangliuyang.520@bytedance.com>
Co-authored-by: black-06 <hello.bug@foxmail.com>
* fix: 🐛 embedded struct test failed with custom datatypes
Fix the pointer embedded struct within custom datatypes and *time.time
should be nil issue.
* fix: 🐛 change test case to avoid mssql driver issue
change test cases from bytes to string to avoid mssql driver issue
* 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>
* 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
Ensures that foreign key relationships and indexes are given
syntactically valid names when their name length exceeds 64 characters
and they contained dot characters within the name. This is most often
relevant when a Postgres table name is fully qualified by including its schema
as part of its name