Jay Taylor
c53f494ff6
Recalculate fields in `Scope.Fields' when empty (nil) or number of fields is LTE 1.
...
Protect the `.fields' variable state from partial-initialization timing
issues.
As gorm warms state and makes `.GetStructFields' calls, they lead to a long
deferred function in model_struct.go. Then the deferred function calls
`Scope.Fields', leading to another `.GetStructFields' call.. cyclically.
Once information is cached the cycling ends.
This extra rule evicts incorrect/suspiciously short fields information.
Symptom of incorrect internal state ocurring can manifest as invalid
insert SQL statement errors generated during `DB.Save', e.g.:
INSERT INTO "your_table" DEFAULT VALUES RETURNING "your_table"."id"
This is why we refresh if nil or only a single field (usually is the ID field).
Included is a unit-test which triggers the scenario and prove that it is
fixed.
2015-08-07 22:17:51 -07:00
Jinzhu
fd9e42655f
Handle children db's Error in callbacks
2015-08-07 16:35:48 +08:00
Jinzhu
d21eed4b66
Don't include Order for counting sql
2015-08-05 15:58:11 +08:00
Jinzhu
6b8f2fcab8
Send a ping to make sure the database connection is alive, thanks @pariz
2015-08-02 07:37:33 +08:00
Jinzhu
0def184b0c
Merge pull request #572 from eirmag/master
...
Table suffix to create tables with InnoDB engine
2015-08-02 07:28:42 +08:00
Gabriel
eef40a06ff
Rename the parameter to table_options and avoid introduction of new API function OpenWithTableSuffix
2015-08-01 22:46:38 +00:00
Jinzhu
a7762ea7d6
Return error happend in Create/Update when using FirstOrCreate
2015-08-01 12:00:35 +08:00
Jinzhu
e2e417a8c2
Fix complicated Select
2015-08-01 11:49:34 +08:00
Jinzhu
f07216e90e
Allow pass blank string to Order
2015-08-01 11:31:36 +08:00
Jinzhu
85a682e820
Update README for AddForeignKey example
2015-08-01 11:28:31 +08:00
Jinzhu
393d8a3a52
Fix possible duplciated foreign key name
2015-08-01 11:27:01 +08:00
Jinzhu
05b3f036f8
Change plural engine to github.com/qor/inflection
2015-08-01 11:20:08 +08:00
Jinzhu
6f30170fec
Use copy logger into itself instead of using parent's
2015-08-01 11:12:39 +08:00
Jinzhu
bee1c8d119
Merge pull request #576 from kiwih/master
...
Add basic support for multiple HAVING clauses.
2015-08-01 10:00:05 +08:00
Jinzhu
8a88d665d5
Add QuoteIfPossible for Scope
2015-08-01 09:25:06 +08:00
Jinzhu
fa86433142
Overwrite initiliazed slices as empty slices
2015-08-01 09:09:09 +08:00
Jinzhu
3f18890ca4
Merge pull request #583 from liudanking/master
...
fix panic in function databaseName()
2015-08-01 08:54:47 +08:00
Jinzhu
6d4a5f75ee
Merge pull request #589 from rghose/patch-1
...
this fixes syntax error for go1.3.3
2015-08-01 08:51:36 +08:00
Rahul Ghose
1c227d4243
this fixes syntax error
...
relevant issue: https://github.com/jinzhu/gorm/issues/588
2015-07-31 16:52:46 +05:30
Jinzhu
25ba9487aa
Create join table with computed foreign keys
2015-07-31 16:33:44 +08:00
Jinzhu
6a7dda9a32
Fix AssociationForeignFieldNames for many2many relations
2015-07-31 15:25:33 +08:00
Jinzhu
f00b95d305
Passed all tests for multiple primary keys
2015-07-30 22:59:25 +08:00
Jinzhu
f50956cfef
Fix test TestSelectWithCreate
2015-07-30 22:36:04 +08:00
Jinzhu
ebbeecd10f
Fix test TestManyToMany
2015-07-30 22:18:56 +08:00
Jinzhu
9c52c29e90
Fix test TestRelated
2015-07-30 18:56:05 +08:00
Jinzhu
7decf73356
Fix test TestHasOneAndHasManyAssociation
2015-07-30 18:41:43 +08:00
Jinzhu
4e8272cf9d
Fix compile error for preload
2015-07-30 18:19:49 +08:00
Jinzhu
fea291e796
Fix compile error for scope_private
2015-07-30 17:58:49 +08:00
Jinzhu
dc428d2364
Fix compile error for association
2015-07-30 17:26:10 +08:00
Jinzhu
a29230c86f
multpile foreign keys
2015-07-30 16:23:51 +08:00
liudan
2fe185eb77
fix panic in function databaseName when there are special characters in password, such as '?', '/'
2015-07-28 16:33:32 +08:00
kiwih
a9cdf1dc7f
Add basic support for multiple HAVING clauses. All clauses will be ANDed together.
2015-07-22 15:00:20 +12:00
Jinzhu
82d726bbfd
Merge pull request #573 from gitter-badger/gitter-badge
...
Add a Gitter chat badge to README.md
2015-07-21 15:06:57 +08:00
The Gitter Badger
e6741c3f1e
Added Gitter badge
2015-07-21 07:03:25 +00:00
Jinzhu
4c3daade4c
Don't quote column if it is not only column name when create index
2015-07-21 10:12:31 +08:00
Gabriel
260000d00f
Propagate argument in open function with table options
2015-07-20 22:46:04 +00:00
Gabriel
8848fc476d
Table suffix to create tables with InnoDB engine with mysql. Alter table is not affected yet, only create table and auto migration
2015-07-19 22:42:48 +00:00
Jinzhu
5663048f13
Merge pull request #559 from jaytaylor/jay/uncover-rows-affected-errors
...
Surface errors emitted by `RowsAffected'.
2015-07-03 10:57:19 +08:00
Jay Taylor
923ca15b6f
Surface errors emitted by `RowsAffected'.
2015-07-02 12:06:06 -07:00
Jinzhu
27a442b5ec
Merge pull request #550 from jaytaylor/jay/quote-alter-table-column-name
...
Added missing field name quoting for DDL statements
2015-06-30 16:39:57 +08:00
Jinzhu
5ddca7c427
Fix table name for association
2015-06-30 10:39:29 +08:00
Jay Taylor
e31752757a
Added missing field name quoting for ALTER TABLE' and
CREATE INDEX' statements.
2015-06-29 15:35:50 -07:00
Jinzhu
308c96ee4c
Add PrimaryFields
2015-06-29 18:04:15 +08:00
Jinzhu
d35a44c5b1
Merge pull request #541 from rohanthewiz/master
...
Provide clear explanation of transaction database handle
2015-06-24 14:18:17 +08:00
Jinzhu
3490fdf366
Merge branch 'jaytaylor-upstream'
2015-06-24 14:10:06 +08:00
Jinzhu
2a1d64c3e0
Return cloned db instance for AddForeignKey
2015-06-24 14:09:59 +08:00
Jinzhu
bdb6fc55e8
Overwrite slice results with Find
2015-06-24 14:05:21 +08:00
Jinzhu
2d802c3445
Overwrite slice results with Find
2015-06-24 13:56:30 +08:00
Jay Taylor
c2c1dd1fc8
Fix errors being inaccessible due to errors being set on different *DB instance than what is returned.
2015-06-23 15:29:44 -07:00
Jinzhu
dbedca4e5f
Don't run auto migrate if join table doesn't exist
2015-06-23 14:19:59 +08:00