* let limit and offset use bind parameter
* format
* format limt_test
* try again
* fix test case fro connpool
* adding driverName for postgres ,if not to do so, the stmt vars will be added a wrong one called pgx.QueryExecModeSimpleProtocol , causing the SQL with limit problem need 1 parameter ,but given two.
* delete trunk files
* restore the test_test.go
* restore test_test.go
* driver/postgres->v1.5.5
* change postgres version rollback to 1.5.4
---------
Co-authored-by: chenchuan <chenchuan@360.cn>
Co-authored-by: jason_chuan <jason_chuan@126.com>
* 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
Preventing it from being interpreted as the string terminator. This is a widely used escape mechanism in SQL standards and is applicable in most relational databases.
* fix: select mytable.* not working
* fix: select mytable.*: will not match `mytable."*"`.
feat: increase readability of code matching table name column name
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)
```
Let's say we have a problem with DSN which leads to dialector initialize error. However DB connection is not created and for some reason line 184 error provides <nil> even though "db" doesn't exist.
Previously, this code leads to:
panic: runtime error: invalid memory address or nil pointer dereference
This fix now doesn't attempt to close non-existant database connection and instead continues, so the proper error is shown. In my case:
[error] failed to initialize database, got error default addr for network 'localhost' unknown