Jinzhu
751a6dde7a
Call after initialize for gorm.Config ( #7518 )
2025-07-15 12:05:03 +08:00
Jinzhu
c44405a25b
Implement Generics API ( #7424 )
...
* Implement Generics API
* Add more generics tests
* Add more tests and Take method
* use delayed‑ops pipeline for generics API
* fix generics tests for mysql
* Support SubQuery for Generics
* Add clause.JoinTable helper method
* Fix golangci-lint error
* Complete the design and implementation of generic version Join
* improve generics version Joins support
* allow configuring select/omit columns for joins via subqueries
* finish generic version Preload
* handle error of generics Joins/Preload
* fix tests
* Add LimitPerRecord for generic version Preload
* fix tests for mysql 5.7
* test for nested generic version Join/Preload
* Add WithResult support for generics API
* test reuse generics db conditions
* fix data race
* remove ExampleLRU test
* Add default transaction timeout support
* fix test
2025-05-25 15:40:40 +08:00
codingplz
8e7ab46c1b
fix: return init dialector error ( #7379 )
...
* fix: return init dialector error
* mock defer
* fix: skip AfterInitialize
---------
Co-authored-by: wenyazhou.13 <wenyazhou.13@bytedance.com >
2025-05-22 10:53:47 +08:00
Jinzhu
e5b867e785
remove unnecessary session-level configuration for prepared statements
2025-05-07 14:56:49 +08:00
Zhaodong Xie
a827495be1
Preparestmt use LRU Map instead default map ( #7435 )
...
* 支持lru淘汰preparestmt cache
* 支持lru淘汰preparestmt cache
* 支持lru淘汰preparestmt cache
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* 只使用lru
* change const export
* Add stmt_store
* refact prepare stmt store
* Rename lru store
* change const export
* ADD UT
* format code and add session level prepare stmt config
* code format according to golinter ci
* ADD UT
---------
Co-authored-by: xiezhaodong <xiezhaodong@bytedance.com >
Co-authored-by: Jinzhu <wosmvp@gmail.com >
2025-04-25 16:22:26 +08:00
Jinzhu
6bfccf8afa
Refactor all tests script
2024-11-21 17:03:31 +08:00
Hansu Park
8020e8c166
refactor: improve logging for unimplemented ErrorTranslator in TranslateError config ( #7225 )
2024-10-09 19:29:48 +08:00
Sérgio Prata Almeida
109f239fae
add DB level propagation for the Unscoped flag ( #7007 )
...
* adds PropagateUnscoped to db Config
* adds PropagateUnscoped test
* adds PropagateUnscoped to Session and sets it accordingly
2024-06-17 11:59:06 +08:00
Rataj
ac07543962
Fixed error message when dialector fails to initialize ( #6509 )
...
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
2023-08-20 19:46:56 +08:00
qqxhb
fef42941ba
feat: rm GetDBConnWithContext method ( #6535 )
...
* feat: rm contextconnpool method
* feat: nil
2023-08-19 21:33:31 +08:00
Aayush Acharya
f473761813
fix: added SkipHooks in db getInstance() ( #6484 )
2023-08-04 10:35:59 +08:00
Lev Zakharov
661781a3d7
feat: add *sql.DB connector that uses database context ( #6366 )
...
* feat: add SQLConnector
* rename
2023-06-05 16:25:05 +08:00
KantaHasegawa
5eaccaa624
reafactor: add nil detection when sqldb return ( #6373 )
...
* reafactor: add null detection when sqldb return
* refactor: Detecting nil in dbConnector.GetDBConn()
* refactor: Revert partial code from c1ea730367
* fix: fix if statement
2023-06-05 16:24:00 +08:00
Lev Zakharov
7a76c042e6
refactor: remove unnecessary prepared statement allocation ( #6374 )
2023-06-05 16:23:17 +08:00
black
c1ea730367
fix: avoid panic when open fails
2023-06-01 15:22:21 +08:00
mohammad ali
26663ab9bf
max identifier length changed to 63 ( #6337 )
...
* 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 >
2023-05-30 10:00:48 +08:00
Zhiheng Lin
32fc201554
fix: avoid coroutine leaks when the dialecter initialization fails. ( #6249 )
...
Co-authored-by: Kevin Lin <kevin.lin@shopee.com >
2023-04-21 22:17:21 +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
Saeid Kanishka
707d70a542
refactor: translate error only when it is not nil ( #6133 )
...
* refactor: translate error only when it is not nil
* refactor: fix the error flow
* refactor: update the error if checks
* Update gorm.go
---------
Co-authored-by: Saeid Saeidee <s.saeidee@sensysgatso.com >
Co-authored-by: Jinzhu <wosmvp@gmail.com >
2023-03-10 16:51:27 +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
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
jessetang
cef3de694d
cleanup(prepare_stmt.go): unnecessary map delete ( #5849 )
2022-11-13 11:12:09 +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
kinggo
12237454ed
fix: use preparestmt in trasaction will use new conn, close #5508
2022-09-22 16:47:43 +08:00
enwawerueli
573b9fa536
fix: correct grammar
2022-08-15 10:28:36 +08:00
Jinzhu
75720099b5
Create a new db in FindInBatches
2022-07-18 18:07:05 +08:00
ZhangShenao
8333844f71
fix variable shadowing ( #5212 )
...
Co-authored-by: Shenao Zhang <shenao.zhang@shopee.com >
2022-03-31 20:57:20 +08:00
Cao Manh Dat
29a8557384
ToSQL should enable SkipDefaultTransaction by default
2022-03-03 09:18:01 +07:00
Jinzhu
a0aceeb33e
Migrator AlterColumn with full data type
2022-02-10 10:40:48 +08:00
Jinzhu
98c4b78e4d
Add Session Initialized option
2022-01-28 19:26:10 +08:00
Jason Lee
8de266b4a7
Add ToSQL support to generate SQL string. ( #4787 )
...
* Add db.ToSQL method for generate SQL string.
* Improve sql builder test for all dialects.
Improve assertEqualSQL test helper for ignore quotes in SQL.
2021-11-01 17:08:54 +08:00
heige
c13f3011f9
feat: adjust SetupJoinTable func if..else code ( #4680 )
2021-10-08 11:05:50 +08:00
heige
50e85e14d4
Code optimize ( #4415 )
...
* optimize gormSourceDir replace
* fmt.Errorf adjust and Optimize for-break
* strings trim
* feat: avoid using the same name field and if..else optimization adjustment
* optimization callbacks/create.go Create func if...else logic
* fix: callbacks/create.go Create func
* fix FileWithLineNum func and add gormSourceDir unit test
* remove debug print and utils_filenum_test.go
2021-06-10 10:21:28 +08:00
Chris Faulkner
15a46bc042
Fix some typos ( #4294 )
2021-04-19 21:03:39 +08:00
Jinzhu
d278ca49ef
sort GORM options before apply
2021-04-09 11:43:24 +08:00
Jinzhu
ad53074f1d
Pass db error to new instance
2021-04-09 11:07:14 +08:00
Jinzhu
73c6d3e64e
Add AfterInitialize error
2021-03-29 18:36:01 +08:00
Jinzhu
0eba7a9ed1
Fix apply option
2021-03-26 14:20:42 +08:00
Jinzhu
a9fe025ef5
Add GetDBConnector interface
2021-03-19 15:55:38 +08:00
Jinzhu
912360097a
Fix Scopes with Migrator, close #4145
2021-03-11 10:36:14 +08:00
heige
bc347758e5
for Config.cacheStore store PreparedStmtDB key ( #4149 )
2021-03-07 10:57:22 +08:00
heige
495ec4bd87
invalid db error and value and invalid value length error ( #4151 )
2021-03-07 10:56:32 +08:00
Jinzhu
294625759c
Fix after initialize db callback
2021-03-05 14:12:55 +08:00
Jinzhu
1476b2f7d4
Fix apply config
2021-03-04 20:37:44 +08:00
Jinzhu
0157099576
Use functional options
2021-03-04 17:40:25 +08:00
Jinzhu
3d3208ed60
initialize config plugins
2021-02-03 16:27:49 +08:00
Jinzhu
7598204dc3
Support FullSaveAssociations for association mode, close #4010
2021-01-29 16:55:26 +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
Qt
f9131e309d
reduce DB's Use method complexity and make it easier to understand ( #3930 )
2021-01-10 10:15:48 +08:00