Commit Graph

251 Commits

Author SHA1 Message Date
Jinzhu db0cc4d60b Fix too long foreign key/checker names, close #4026 2021-02-01 10:37:12 +08:00
Jinzhu 916338a9e1 Test migrate constraints, close #3986 2021-01-26 13:39:34 +08:00
Jinzhu 6095dbf939 Fix parse embedded relations, close #3964, #3965 2021-01-19 15:40:04 +08:00
Lisa Casner ce610a9560
title case schema name (#3940) 2021-01-13 13:05:05 +08:00
Jinzhu b864a5457a Allow foreign key following the default naming conventions, close #3928 2021-01-10 17:32:17 +08:00
Jinzhu 79864af9ff Allow customize auto increment increment 2020-12-30 11:16:40 +08:00
Jinzhu 065787c54e Compatible with with foreign key with ID suffix #3890 2020-12-28 18:20:55 +08:00
Jinzhu 8bf50a5592 Fix parse relations if only specfied References, close #3890 2020-12-28 17:58:12 +08:00
Jinzhu 6a0fca2195 Return error for invalid relations definition, close #3830 2020-12-06 18:07:16 +08:00
Jinzhu f655041908 Allow overwrite ignored field's permission, close #3829 2020-12-06 11:07:05 +08:00
Andy Bursavich 61d3a4d6ea
Fix schema initialization paths (#3825)
* Fix schema initialization paths

The initialized channel was only closed if the schema's cacheStore did not contain the embeddedCacheKey and there were no errors parsing relations.  If the key existed or an error occurred, it would not be closed. This could leave other goroutines waiting for synchronization that will never occur.

Additionally, the other code paths that wait for initialization to complete did not return the possible error.

* Unnest common schema initialization

This makes the common code path less deeply nested and the flow control easier to follow.
2020-12-04 11:28:38 +08:00
Jinzhu 0f77500917 Waiting for schema to be initialized, close #3790 2020-11-27 17:05:45 +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
Jinzhu 66e8a72bf1 Support NameReplace for NamingStrategy, close #3779 2020-11-23 11:24:07 +08:00
alresvor a4c0c6b400
cache converted name (#3736)
BenchmarkToName-8     	  2322307	       521 ns/op	      88 B/op	       5 allocs/op
↓
BenchmarkToName-8     	19997366	        55.0 ns/op	       0 B/op	       0 allocs/op
2020-11-16 15:16:15 +08:00
Jinzhu 1e241aa645 Reduce GC alloc 2020-11-10 21:23:20 +08:00
Jinzhu cb591a7129 Fix panic when using FirstOrCreate with soft delete, close #3671 2020-10-23 18:40:05 +08:00
Jinzhu 5fee5b1b24 Add option tag support for index 2020-10-21 20:18:21 +08:00
Jinzhu 3d846957cd Compatible with tag notNull 2020-10-09 17:42:28 +08:00
Jinzhu a2faa41cbe Refactor NamingStrategy, close #3540 2020-09-28 10:55:27 +08:00
Jinzhu ba253982bf Fix Pluck with Time and Scanner 2020-09-24 20:08:24 +08:00
Jinzhu 1a526e6802 Fix NamingStrategy with embedded struct, close #3513 2020-09-24 11:32:38 +08:00
Jinzhu ed1b134e1c Fix use uint to for autoCreateTime, autoUpdateTime 2020-09-11 17:33:31 +08:00
Jinzhu b8a74a80d7 Fix embedded struct with default value, close #3451 2020-09-11 11:18:54 +08:00
Jinzhu 231effe119 Fix parse blank default value, close #3442 2020-09-10 11:59:18 +08:00
Jinzhu f6ed895caf Build relationships if fields are not ignored, fix #3181 2020-09-09 16:37:05 +08:00
Jinzhu 6e38a2c2d5 Fix many2many join table name rule 2020-09-06 10:51:21 +08:00
Jinzhu f121622228 Don't add prefix for invalid embedded fields 2020-09-04 14:35:44 +08:00
Jinzhu 6a86646469 Fix use db function as integer's default value, close #3384 2020-09-03 20:41:00 +08:00
Jinzhu 78e9c9b748 raise error when failed to parse default value, close #3378 2020-09-03 18:20:57 +08:00
Jinzhu f2adb088c5 Set field size from primary fields to foreign fields 2020-09-03 16:11:15 +08:00
Jinzhu dbe0f4d8d7 Allow use NULL as default value for string, close #3363 2020-09-02 20:15:12 +08:00
aimuz 9a101c8a08
fmt.Sprint() to strconv.Format (#3354) 2020-09-01 21:03:37 +08:00
Jinzhu 162367be7d Fix multiple M2M relations on one table, close #3347 2020-09-01 11:30:16 +08:00
Jinzhu 53f8c9fc1c More compatible prioritized primary field #3156 2020-08-30 20:58:14 +08:00
Jinzhu c19a3abefb Fix self-referential belongs to, close #3319 2020-08-28 11:31:13 +08:00
Jinzhu ce8853e7a6 Add GormValuer interface support 2020-08-27 15:03:57 +08:00
Jinzhu 0f3201e73b friendly invalid field error message 2020-08-25 18:18:16 +08:00
Jinzhu cc6a64adfb Support smart migrate, close #3078 2020-08-23 18:16:12 +08:00
Jinzhu 2b510d6423 Don't create index for join table, close #3294 2020-08-21 15:40:50 +08:00
Jinzhu f88e8b072c Check valid pointer before use it as Valuer 2020-08-20 18:13:29 +08:00
Jinzhu 06de6e8834 Test same field name from embedded field, close #3291 2020-08-20 10:58:35 +08:00
Jinzhu 3313c11888 Fix embedded struct containing field named ID, close #3286 2020-08-19 19:15:27 +08:00
Jinzhu c1782d60c1 Fix embedded scanner/valuer, close #3283 2020-08-19 15:47:08 +08:00
Jinzhu dc48e04896 Fix nested embedded struct, close #3278 2020-08-18 11:21:40 +08:00
Jinzhu 681268cc43 Refactor Create/Query/Update/DeleteClauses interface 2020-08-17 16:31:09 +08:00
Jinzhu 6834c25cec Fix stack overflow for embedded self-referred associations, close #3269 2020-08-17 12:02:46 +08:00
Jinzhu 7d45833f3e Fix driver.Valuer interface returns nil, close #3248 2020-08-13 12:05:55 +08:00
Jinzhu a3dda47afa Don't parse ignored anonymous field 2020-08-13 10:23:23 +08:00
Jinzhu ff985b90cc Fix failed to guess relations for embedded types, close #3224 2020-08-04 12:25:34 +08:00
Jinzhu f83b00d20d Fix Count with Select when Model not specfied, close #3220 2020-08-03 10:30:25 +08:00
Jinzhu 2676fa4fb8 Remove autoincrement tag for join table, close #3217 2020-07-31 18:19:25 +08:00
lninl 7bb883b665
Auto creating/updating time with unix (milli) second (#3213)
* Auto creating/updating time with unix (milli) second

* add test for 'Auto creating/updating time with unix (milli) second'
2020-07-30 17:39:57 +08:00
Jinzhu 47a5196734 Fix uninitialized Valuer return time.Time, close #3214 2020-07-30 17:37:07 +08:00
Jinzhu 7c2ecdfc1c Fix use pointer of Valuer as foreign key, close #3212 2020-07-30 10:23:35 +08:00
Jinzhu 2cbdd29f26 Returns error for invalid embedded field, close #3209 2020-07-29 10:23:14 +08:00
Jinzhu 7021db3655 Fix FieldsWithDefaultDBValue for primary field, close #3187 2020-07-22 19:03:19 +08:00
Jinzhu ef002fd7ac Add GORMDataType to Field, close #3171 2020-07-20 19:00:03 +08:00
Jinzhu 6dc583869b Don't use value's first field to guess data type for struct implements GormDataTypeInterface 2020-07-17 12:02:00 +08:00
Jinzhu 4456df7a5d Lint with golangci-lint 2020-07-16 11:27:12 +08:00
Jinzhu 0028246ea5 Don't set DefaultValueInterface when DefaultValue not set, close #3152 2020-07-16 10:19:24 +08:00
Jinzhu bc3728a18f Fix concurrent map writes, close #3126 2020-07-10 07:14:37 +08:00
Jinzhu 2ae0653af2 Fix ambiguous column when using same column name in join table, close #3120 2020-07-09 09:03:48 +08:00
Jinzhu e1084e78d0 Allow customize AutoIncrement for primary field 2020-07-08 18:50:49 +08:00
Jinzhu 619cd332ec Add index priority supports 2020-07-08 17:59:40 +08:00
Jinzhu 90a40361ed Fix set bool field from null 2020-07-04 08:21:23 +08:00
Jinzhu 6b98ced13d Fix set time field from null, close #3108 2020-07-04 07:45:07 +08:00
Jinzhu d4f8a52442 Fix join table foreign key in snake_case 2020-07-04 07:24:46 +08:00
Jinzhu 2416eabd3f Change unique_idnex to UniqueIndex 2020-07-04 00:36:27 +08:00
Jinzhu fea181e87c Test multiple index tags 2020-07-01 11:47:46 +08:00
Jinzhu 2d048d9ece SingularTable for JoinTable 2020-06-30 07:29:15 +08:00
Jinzhu 2476c0fbb4 Set db type after autotime 2020-06-26 07:26:45 +08:00
Hinagiku Soranoba b733d16f56
Create supports Array / ArrayPtr (#3076)
* add Array / ArrayPtr create tests

* support create using array
2020-06-23 14:38:36 +08:00
Jinzhu e77e7bb842 Fix nested embedded field with pointer, close #3071 2020-06-23 09:12:57 +08:00
Jinzhu d0764bead1 Test migrate with comment and check created constraints 2020-06-21 13:59:43 +08:00
Jinzhu fee1e4aafd Fix create foreign keys for many2many relations 2020-06-21 10:48:23 +08:00
Jinzhu a1e35bdc94 Support merge batch data some having primary values 2020-06-20 16:52:15 +08:00
Jinzhu 4f19e2a7b3 Test ForeignKeyConstraints 2020-06-20 01:20:18 +08:00
Jinzhu d4d339f3b5 Handle data type cases 2020-06-19 22:51:46 +08:00
Jinzhu 07960fe661 Fix []byte support 2020-06-18 11:24:08 +08:00
Jinzhu 96368eb967 Test embedded struct implements Scan & Value interface 2020-06-18 09:15:23 +08:00
Jinzhu 6b2f37189e Fix few cases with postgres 2020-06-18 08:40:41 +08:00
Jinzhu a954d772d7 Support customize gorm field type 2020-06-06 10:47:32 +08:00
Jinzhu 1490a062db Refactor codebase and add benchmark test 2020-06-05 23:26:56 +08:00
Jinzhu d50879cc28 Add field permission test 2020-06-05 19:18:22 +08:00
Jinzhu b32658358c Fix can't scan null value into normal data types 2020-06-03 09:00:20 +08:00
Jinzhu 94685d1024 Fix can't scan null value into normal data types 2020-06-02 23:30:26 +08:00
Jinzhu 2218e32999 Allow customize table name with TableName 2020-06-02 15:48:19 +08:00
Jinzhu 8bb05a5a69 Refactor tests files 2020-06-02 10:50:38 +08:00
Jinzhu 5790ba9ef4 Fix package path 2020-06-02 09:25:55 +08:00
Jinzhu e986371a42 Rename package name 2020-06-02 09:18:01 +08:00
Jinzhu 5ecbf25b22 Drop table with CASCADE option 2020-06-02 07:56:53 +08:00
Jinzhu b71171dd92 Add more preload tests 2020-06-02 01:34:00 +08:00
Jinzhu e490e09db5 Add SetupJoinTable support 2020-06-01 23:58:22 +08:00
Jinzhu 1559fe24e5 Add more updates test 2020-06-01 19:41:33 +08:00
Jinzhu 76b8e78dcb Add multi primary keys test 2020-06-01 08:13:16 +08:00
Jinzhu befef0c9a9 Improve Hooks 2020-06-01 00:12:20 +08:00
Jinzhu 49310d0974 Test override foreign key, reference 2020-05-31 17:42:21 +08:00
Jinzhu 6d555ef8d5 Test embedded struct 2020-05-31 14:18:07 +08:00
Jinzhu 7c0de9199c Test Migrate Indexes 2020-05-30 22:43:41 +08:00
Jinzhu c291c2f42c Add Scanner, Valuer tests 2020-05-30 21:05:27 +08:00
Jinzhu 028c9d6e17 Test Updates 2020-05-30 17:01:28 +08:00
Jinzhu abae7f71c5 Test non std primary key and default value 2020-05-30 16:03:27 +08:00
Jinzhu 6f4602af11 Fix mysql tests 2020-05-29 23:38:03 +08:00
Jinzhu 55074213bc Add SoftDelete support 2020-05-29 07:35:45 +08:00
Jinzhu cc064f26ee Add on conflict support 2020-05-25 23:11:42 +08:00
Jinzhu 5d9b57cc4e Test HasMany Association 2020-05-25 11:11:09 +08:00
Jinzhu 68a7a8207a Test HasOne Association 2020-05-24 23:07:42 +08:00
Jinzhu 91a695893c Test Association For BelongsTo 2020-05-24 18:33:15 +08:00
Jinzhu e60a8d54ff Test Nested Preload 2020-05-24 00:52:25 +08:00
Jinzhu 590f622674 Refactor create tests 2020-05-23 22:32:16 +08:00
Jinzhu 5ec4fee797 Don't preload if foreign keys zero 2020-05-23 21:09:03 +08:00
Jinzhu 20cb57b1ac Add association Delete support 2020-05-20 02:03:43 +08:00
Jinzhu 922a8efc53 Generate Query Conds for Relationship 2020-05-19 21:50:06 +08:00
Jinzhu 59365b776b Refacotr Preload 2020-05-18 13:07:11 +08:00
Jinzhu 8def7be583 Add context to logger 2020-05-05 21:28:38 +08:00
Jinzhu 56ca9a87e0 Add permission check when create associations 2020-04-16 10:29:18 +08:00
Jinzhu e1bcca6b33 Compatible with tag PRIMARY_KEY 2020-04-12 13:16:15 +08:00
Jinzhu a46d48ccb3 Add tests for controlling field permission with tag 2020-04-08 08:32:28 +08:00
Jinzhu 29cd35219f Add creatable, updatable, readable permission 2020-04-08 08:15:00 +08:00
Jinzhu d39bdc3513 Fix create index 2020-04-03 07:57:52 +08:00
Jinzhu f7f633590f Fix tests with mysql, postgres 2020-03-12 13:05:22 +08:00
Jinzhu af080e6773 Fix primary key tag 2020-03-12 08:39:42 +08:00
Jinzhu 2da0ad5bed Add more tests for Update 2020-03-08 13:24:08 +08:00
Jinzhu b0e1bccf4a Support scan into map, slice, struct 2020-03-04 11:33:50 +08:00
Jinzhu 04adbaf7f6 Fix parse stmt ReflectValue 2020-02-24 08:51:35 +08:00
Jinzhu e2a360b9fa Add Before/After callbacks 2020-02-23 21:22:35 +08:00
Jinzhu fa22807e12 Make inesrt into db works 2020-02-23 19:41:29 +08:00
Jinzhu fe24c3f105 Setup tests script 2020-02-23 09:38:51 +08:00
Jinzhu 6d58b62fd4 Add sqlite migration tests 2020-02-22 20:57:29 +08:00
Jinzhu 215f5e7765 Add Raw, Row, Rows 2020-02-22 19:41:01 +08:00
Jinzhu fab7d96da5 Add DataTypeOf for dialector 2020-02-22 17:53:57 +08:00
Jinzhu 0be4817ff9 Finish CreateConstraint 2020-02-22 11:15:51 +08:00
Jinzhu ea0b13f7a3 Refactor ParseTagSetting 2020-02-22 07:59:09 +08:00
Jinzhu ad419855e9 Parse Indexes 2020-02-21 23:51:38 +08:00
Jinzhu 43ce0b8af2 Handle create with default db values 2020-02-20 10:13:26 +08:00
Jinzhu cbbf8f3d49 Update schema 2020-02-18 22:56:37 +08:00
Jinzhu 18236fa3d7 Add more tests for setter, valuer 2020-02-16 00:37:59 +08:00
Jinzhu faee069a9f Test Field Valuer, Setter 2020-02-15 20:28:03 +08:00
Jinzhu 2cb88dc7c5 Add Field Valuer, Setter 2020-02-15 18:24:37 +08:00
Jinzhu d833efe8b9 Work on clauses 2020-02-02 19:11:17 +08:00
Jinzhu 8cb15cadde Improve test structure 2020-02-02 08:35:01 +08:00
Jinzhu 3cbd233758 Add more tests for parse schema relations 2020-02-02 00:03:56 +08:00
Jinzhu a4a0895a85 Test parse schema relations 2020-02-01 22:26:17 +08:00
Jinzhu 14724ddeae Add tests model definition and basic fields tests 2020-02-01 20:18:32 +08:00
Jinzhu fd9b688084 Implement parse many2many relation 2020-02-01 18:02:19 +08:00
Jinzhu a9c20291e4 Implement guess relation 2020-02-01 15:23:45 +08:00
Jinzhu eea78f3f30 Implement parse relationship architecture 2020-02-01 12:46:52 +08:00
Jinzhu 010dc7e6dd Add namer when generate schema 2020-01-31 14:31:15 +08:00
Jinzhu bc68fde6aa Implement naming strategy 2020-01-31 14:17:02 +08:00