Jinzhu
308c96ee4c
Add PrimaryFields
2015-06-29 18:04:15 +08:00
Jinzhu
0b8c9f29a9
Find Field by db name also
2015-06-04 12:10:14 +08:00
Jinzhu
b96ca76e59
Set table name handler
2015-05-27 12:19:48 +08:00
Jinzhu
dc55c59b84
Fix use SQL as table name
2015-05-19 10:43:32 +08:00
Jinzhu
5af077cd2d
Handle []string for Select
2015-05-11 15:17:35 +08:00
Jinzhu
055bf79f8b
Don't call method if value is nil
2015-04-21 11:24:48 +08:00
li3p
f9bd6bcc64
look up the Field.Name at Scope.SetColumn
2015-04-16 14:28:55 +08:00
li3p
7966cde514
look up the Field.Name at Scope.SetColumn
2015-04-16 14:08:13 +08:00
Jinzhu
e2eef50fb4
Add SetTableNameHandler
2015-04-08 14:56:03 +08:00
Jinzhu
b9a39be9c5
Add Tabler
2015-04-08 11:36:01 +08:00
Jay Taylor
ab48cd222a
`UpdateColumns(...)` no longer triggers save of associated records.
2015-03-28 14:15:12 -07:00
Jinzhu
2989e42d4d
Support UpdateColumn with Select and Omit
2015-03-13 11:01:05 +08:00
Jinzhu
187eae8d9c
Update with Select and Omit
2015-03-12 18:30:59 +08:00
Jinzhu
ad251b9deb
Create with Select
2015-03-12 17:47:31 +08:00
Jinzhu
6e5d46bf37
Refactor Search API
2015-03-12 14:47:07 +08:00
Jinzhu
49454839bd
Support Multi primary keys
2015-03-11 11:28:30 +08:00
Jinzhu
33e6b14632
Clear value from db after set table name
2015-02-26 16:08:26 +08:00
Jinzhu
ce72988e96
Refactoring API for plugin system
2015-02-26 14:40:30 +08:00
Jinzhu
10340e6ad7
Support SQL expression
2015-02-24 22:06:35 +08:00
Jinzhu
0f08058713
Fix quote table name with database
2015-02-24 18:02:22 +08:00
Jinzhu
83ee11e184
Don't call callbacks if has error
2015-02-24 16:28:15 +08:00
Jinzhu
406a01875c
Test using pointer as struct fields
2015-02-20 22:06:49 +08:00
Jinzhu
5c478b46e1
Use Common Initialisms from golint
2015-02-18 10:36:32 +08:00
Jinzhu
672ba4ffc9
Rename ToSnake to ToDBColumnName
2015-02-18 09:26:35 +08:00
Jinzhu
9b355ee86c
Fix Associations with slice of pointer
2015-02-17 23:36:23 +08:00
Jinzhu
0b32041135
Review and Refactor
2015-02-17 22:55:14 +08:00
Jinzhu
a38f83527a
Fix all tests
2015-02-17 18:37:47 +08:00
Jinzhu
d6439f4147
Fix tests after refactor
2015-02-17 18:01:24 +08:00
Jinzhu
803343fbe5
Fix scope.getField
2015-02-17 14:30:37 +08:00
Jinzhu
139b9a37e7
Merge branch 'master' into refactor
2015-02-17 08:38:32 +08:00
Jinzhu
73b6f0eace
Linting according to golint
2015-02-17 08:34:01 +08:00
Andrew Martin
52775992ec
golinting
2015-02-17 10:15:34 +11:00
Jinzhu
de3f2a5c46
Refactor Fields
2015-02-16 17:47:07 +08:00
Jinzhu
3a73206010
Refactor model struct
2015-02-16 16:35:26 +08:00
Jinzhu
5d692a6bf2
Try to cache struct fields
2015-02-15 23:01:09 +08:00
Jinzhu
87b23edd3b
Fix get PrimaryKeyField with embedded struct
2015-02-11 18:10:59 +08:00
Jinzhu
aac52fdcf8
Fix Preload with slice of pointer
2015-02-11 17:58:19 +08:00
deoxxa
d3ffcfab40
check for IsScanner on slices
2015-01-30 21:25:11 +11:00
Jinzhu
3e9c2d581f
Fix duplicated instanceId in edge case
2015-01-26 17:59:31 +08:00
Jinzhu
e2c989be17
Remove unnecessary IsIgnored check
2015-01-23 09:04:07 +08:00
Jinzhu
2069364296
HasColumn with ignored column
2015-01-19 16:23:33 +08:00
Jinzhu
ebe5f191a9
Fix upper case for primary key
2015-01-16 10:02:04 +08:00
Jinzhu
3500dfa1b6
expose db.New as API
2015-01-06 15:11:41 +08:00
Jinzhu
6d13ae4ead
Merge pull request #303 from jnfeinstein/dev_poly
...
Support polymorphic has-one and has-many associations
2014-11-28 10:10:47 +08:00
jnfeinstein
a8492826a8
Fields are only cached when withRelation, so they should only be accessed when withRelation.
...
The result of .Fields() is quite different with and without withRelation.
I assume that if you call it without withRelation, you don't want the
fields that were cached when withRelation was true.
2014-11-27 14:04:05 -08:00
jnfeinstein
8b451f0084
Add support for polymorphic relationships using the POLYMORPHIC setting.
...
This commit adds support for two settings:
FOREIGNTYPE - A field that is used to store the type of the owner.
POLYMORPHIC - A shortcut to set FOREIGNKEY and FOREIGNTYPE to the same
value suffixed by "Id" and "Type" respectively.
The type is stored as the table name, which I thought might be useful
for other queries.
The biggest gotcha of this commit is that I flipped the definition of
has_one and belongs_to. gorm is very flexible such that it didn't
really care if it was a has_one or belongs_to, and can pretty much
determine it at runtime. For the sake of the error, I had to define
one of them as belongs_to, and I chose the one with the fields as
the belongs_to, like ActiveRecord. The error could probably be
genericized to "gorm cannot determine type", but I think it's nicer
to tell people DONT DO PATTERN XYZ CAUSE IT WONT WORK. Functionally,
it doesn't matter.
2014-11-25 21:35:47 -08:00
Jinzhu
e9684db42a
Show error message if not using addressable value for auto migration
2014-11-25 13:44:14 +08:00
Paolo Galeone
064d91335b
Add default values support ( https://github.com/jinzhu/gorm/issues/251 )
2014-11-15 18:32:35 +01:00
Jinzhu
010e7a90b3
Fix can't update record with customized primary key
2014-11-11 11:46:21 +08:00
Jinzhu
6c1ca7adb8
Include ignored columns in Fields(), it could be used as cache field
2014-10-14 00:06:41 +08:00
Vytautas Šaltenis
67f71b2f86
Fix a bug with custom columns and ignored fields
...
An ignored field should also be ignored when column names are being
determined.
2014-10-10 00:05:15 +03:00
Jinzhu
0aaefebf4f
Add support for custom column names
2014-10-07 22:37:33 +08:00
Tristan Storch
41eeeeea7c
Cheanged if to switch in scope.go
...
Readability improved by changing a long if-else to a switch statement.
2014-10-06 11:11:07 +02:00
Jinzhu
375f3ee260
Merge pull request #239 from tstorch/cleanup
...
FieldValueByName does now only what it should
2014-10-03 13:32:18 +08:00
Tristan Storch
9bee4239d4
FieldValueByName does now only what it should
...
FieldValueByName in utils.go does now only what it should and has proper errors.
2014-10-01 16:20:12 +02:00
Tristan Storch
f1212ecd58
Readability update
...
Small readability update. Includes also a switch from bool return values to
error return values in Scope.SetColumn and Field.Set.
2014-09-30 14:02:51 +02:00
Tristan Storch
f771ee21da
Minor Refactoring for readability
...
Refactored of a small portion if the scope code for readability
2014-09-26 15:35:04 +02:00
Jinzhu
953c347ba7
Refactor Scope
2014-09-02 19:03:01 +08:00
Jinzhu
b6d934aff9
Improve HasColumn method, support embedded struct
2014-09-01 17:04:07 +08:00
Jinzhu
7862dace6b
Don't panic if can't get address
2014-09-01 14:15:29 +08:00
Jinzhu
c6b1669c6a
Fix tests for Scanner
2014-08-30 23:14:14 +08:00
Jinzhu
6271cf0e55
Fix tests for postgres
2014-08-30 22:39:28 +08:00
Jinzhu
471eda5a12
Panic if found duplicated column name
2014-08-30 21:42:35 +08:00
Jinzhu
d806b7084f
Pass anonymous struct tests
2014-08-30 21:42:35 +08:00
Jinzhu
b2360c11da
Add Fields for embedded struct
2014-08-30 21:42:35 +08:00
Jinzhu
423d9496c1
update tests
2014-08-28 16:14:44 +08:00
Jinzhu
8f22434ded
Use the original DB when create a new Scope
2014-08-27 16:50:22 +08:00
Jinzhu
5347765bd3
Merge pull request #206 from cihangir/master
...
gorm: added ability to change the time.now format
2014-08-27 16:19:55 +08:00
Jinzhu
922395c965
Add InstantSet for DB
2014-08-25 17:10:46 +08:00
Cihangir SAVAS
4e90fbf4e8
gorm: added ability to change the time.now format
2014-08-23 01:00:04 -07:00
Jinzhu
39ac95adbb
Add InstanceSet, InstanceGet fomr Scope
2014-08-20 17:05:02 +08:00
Jinzhu
9012c9ea09
Add Set, Get method for DB
2014-08-20 16:25:01 +08:00
Jinzhu
a80a0a1636
By default, pluralize table name
2014-08-20 13:46:10 +08:00
Jinzhu
10668ee323
Don't raise error when get TableName even Scope has no db
2014-08-20 10:49:48 +08:00
Jinzhu
07e2d49b22
Fix invalid reflect value
2014-08-15 11:14:33 +08:00
Jinzhu
febc826511
Don't check relations if field is ignored
2014-08-14 21:54:23 +08:00
Jinzhu
90106d82c5
Export Relationship
2014-07-31 14:38:16 +08:00
Jinzhu
6c4b635176
Replace BeforeAssociation, AfterAssociation with association type
2014-07-30 21:14:10 +08:00
Jinzhu
2356182ea7
Rename joinTable to relationship
2014-07-30 20:59:52 +08:00
Jinzhu
e1e68debdc
improve association
2014-07-30 20:48:36 +08:00
Jinzhu
9b3be66a77
Refact scope Fields
2014-07-30 15:15:23 +08:00
Jinzhu
0d3085393e
Add IndirectValue for Scope
2014-07-30 14:58:00 +08:00
Jinzhu
14590a65dc
Save many to many relations into join table
2014-07-30 14:18:15 +08:00
Jinzhu
a7aaf151cf
Use JoinTable instead of ForeignKey
2014-07-30 11:32:18 +08:00
Jinzhu
0c63e57f5c
Use tag to set primary key
2014-07-29 18:21:36 +08:00
Jinzhu
2d3bcf5297
Refact untils.go
2014-07-25 16:53:28 +08:00
Jinzhu
40c16f3c29
Export method ToSnake and SnakeToUpperCamel
2014-07-21 14:06:54 +08:00
Jinzhu
3eb4adafba
Extract method FieldByName
2014-07-15 11:53:17 +08:00
Jinzhu
3bd5131132
Support slice of pointers
2014-07-08 10:45:31 +08:00
Jinzhu
325e6c2ef1
Fix tests with go v1.3
2014-07-02 11:56:44 +08:00
Jinzhu
11f232a200
Fix QuotedTableName
2014-06-10 13:08:19 +08:00
Jinzhu
f32fa0cb6e
Add RowsAffected for DB
2014-06-05 17:58:14 +08:00
Jinzhu
0cba662be0
Add method QuotedTableName for Scope
2014-06-03 17:17:30 +08:00
Jinzhu
a46d149579
remove package dialect for easier contribution
2014-04-25 07:20:23 +08:00
Paolo Galeone
bcb1ca67c0
Add support for primary key different from id
2014-04-06 04:10:45 +02:00
Jinzhu
d7d9e24e1e
Add test for anonymous field
2014-03-26 08:36:17 +08:00
Jinzhu
1086009fce
Check if value is struct before check Field
2014-03-11 10:09:16 +08:00
Jinzhu
91e937bac1
Add some documents
2014-01-29 19:14:37 +08:00
Jinzhu
5eed96457b
rename couple of scope related methods
2014-01-29 12:00:57 +08:00
Jinzhu
241b6bc3b9
refact
2014-01-29 10:35:28 +08:00
Jinzhu
31247c577d
update method CombinedConditionSql
2014-01-29 08:55:45 +08:00
Jinzhu
036df5f46b
Move scope_database to scope.go
2014-01-28 17:40:09 +08:00
Jinzhu
6f1dd5fae3
API for search
2014-01-28 16:56:51 +08:00
Jinzhu
15583e6017
rename some files
2014-01-28 16:29:42 +08:00
Jinzhu
f1d990e92a
rename scope.quote to scope.Quote
2014-01-28 16:22:41 +08:00
Jinzhu
a2edf56c58
Remove unused codes
2014-01-28 16:06:22 +08:00
Jinzhu
2adbc4b8a6
move all code to scope
2014-01-28 15:54:19 +08:00
Jinzhu
05ce3d3933
related with plugin system
2014-01-28 12:28:44 +08:00
Jinzhu
ae68c0fb47
make count works
2014-01-28 11:38:53 +08:00
Jinzhu
5fd2e0d54f
make pluck works
2014-01-28 11:37:32 +08:00
Jinzhu
7bebf685f4
refact
2014-01-28 10:23:31 +08:00
Jinzhu
275de4f133
Add method inlineCondition
2014-01-28 10:06:03 +08:00
Jinzhu
6e848fc987
move row, rows, scan to scope
2014-01-28 09:48:44 +08:00
Jinzhu
db68e7a8fe
make callback query works
2014-01-28 09:25:30 +08:00
Jinzhu
048b8b6abe
make update column works with new plugin system
2014-01-28 08:27:12 +08:00
Jinzhu
506d14a2f2
make callback deletes works
2014-01-27 22:36:08 +08:00
Jinzhu
eab146a275
Add getter setter for scope
2014-01-27 12:02:35 +08:00
Jinzhu
23feade663
use callback update when save
2014-01-27 11:25:55 +08:00
Jinzhu
3981baf65d
Make callback create pass all tests
2014-01-27 10:47:37 +08:00
Jinzhu
ee6a6827a8
implement callback shared
2014-01-27 08:26:59 +08:00
Jinzhu
8dd7b4ed91
make callback create works
2014-01-26 19:36:15 +08:00
Jinzhu
261ece5696
Make callback delete works
2014-01-26 17:10:33 +08:00
Jinzhu
4985d7bd96
Add scope_condition.go
2014-01-26 14:58:29 +08:00
Jinzhu
6775ecaf13
delete unused callbacks/create.go
2014-01-26 14:28:35 +08:00
Jinzhu
10fcb0c88e
update scope.go
2014-01-26 14:18:21 +08:00
Jinzhu
79cacf7f09
improve scope.go
2014-01-26 13:51:23 +08:00
Jinzhu
973acd6339
Add callback create, delete
2014-01-26 12:41:37 +08:00