Commit Graph

87 Commits

Author SHA1 Message Date
Jinzhu da7830ea50 Add SelectAttrs, OmitAttrs 2015-03-12 15:50:38 +08:00
Jinzhu 94adc3e1d8 Export Unscoped Field for search 2015-03-12 15:01:59 +08:00
Jinzhu 6e5d46bf37 Refactor Search API 2015-03-12 14:47:07 +08:00
Jinzhu a549b6bd49 Refactor SQL Tag 2015-03-11 17:05:58 +08:00
Jinzhu 49454839bd Support Multi primary keys 2015-03-11 11:28:30 +08:00
Jason Lee 708d85763c Dialect Index first, before AddIndex 2015-03-09 21:33:25 +08:00
Jinzhu 6fed43162f Create Indexes with AutoMigrate 2015-03-09 17:22:16 +08:00
Jinzhu 42f934d60e Fix nil condition 2015-03-06 10:49:26 +08:00
Jinzhu 80576bbbbc Add Table method for JoinTableHandler 2015-03-04 13:56:47 +08:00
Jinzhu 61a878dc2d Fix Related for belongs to association 2015-03-02 15:55:24 +08:00
Jinzhu 4e8d43dd4f Refactor check HasTable, HasColumn 2015-02-28 17:01:27 +08:00
Jinzhu 22b1a93e03 Add JoinTableHandler test 2015-02-28 14:16:51 +08:00
Jinzhu aa0a4012be Escaping table names when AddForeignKey 2015-02-28 09:25:05 +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 068e774540 Overwrite Select conditions 2015-02-23 08:58:52 +08:00
Jinzhu 49a33dd5d0 Remove other select conditions for count 2015-02-22 22:40:12 +08:00
Jinzhu 0d2c37e310 Refactor Model Struct 2015-02-18 12:50:37 +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 0b32041135 Review and Refactor 2015-02-17 22:55:14 +08:00
Jinzhu d6439f4147 Fix tests after refactor 2015-02-17 18:01:24 +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 f37ccf2a7e more linting 2015-02-17 10:21:18 +11:00
Andrew Martin f9638f3633 linting 2015-02-17 10:19:42 +11:00
Jinzhu f4e705b749 Fix compile error 2015-02-16 16:42:01 +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
Vytautas Šaltenis 76d1d1e1cc Fix typo: Condiation -> Condition 2015-02-11 21:14:34 +02:00
Jinzhu 6dc33d6d94 Merge pull request #360 from sendyhalim/scope-add-foreignkey
Add Scope.addForeignKey()
2015-02-11 19:35:57 +08:00
Jinzhu dd635a17c2 Preload belongs_to, has_one, has_many relations 2015-02-11 13:43:53 +08:00
Jinzhu 9757958106 Fix pointers for AutoMigrate 2015-02-09 21:14:48 +08:00
sendyHalim a8b3e8d3e2 Add Scope.addForeignKey() 2015-02-07 18:04:10 +07:00
Jinzhu b33f30714b Fix Error when using custom columns with ignored fields 2015-02-05 17:42:24 +08:00
Jinzhu e2c989be17 Remove unnecessary IsIgnored check 2015-01-23 09:04:07 +08:00
Jinzhu 5330572c25 Fix Exec with raw string 2015-01-20 14:55:38 +08:00
Jinzhu f8e4e16e09 Fix Where with string 2015-01-20 11:30:01 +08:00
Andrew Brampton fef286a7bc Fixes #335 - Added scoped table name to "deleted_at" where clause. This ensures it works when the deleted_at column is ambigious, for example, during a join. 2015-01-11 13:49:36 -08:00
Jinzhu 1e6e785651 Fix return incorrect sql type 2015-01-05 08:43:13 +08:00
Constantin Schomburg 045b4d6d2a Fix error when chaining empty where conditions 2015-01-04 13:47:25 +01: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 1aaac379ae Fix tests for mysql, postgres 2014-11-24 18:16:07 +08:00
Shirou WAKAYAMA e313827f04 fix panic problem when the struct has unexported field. 2014-11-19 12:44:57 +09:00
jnfeinstein 429a100856 Add additional methods of specifying the 'select' portion of a query.
This commit adds more ways of specifying selects:

-) You can now pass in a []string.  This is mostly for convenience,
since you may want to dynamically create a list of fields to be
selected.

-) You can now use variables.  This is important because a select
could take user input.  For example, finding a MAX between a record
and a given number could be easily done using select, and then
you don't have to process anything in backend logic.  This is also
necessary to use postgres text search capabilities (which actaully
play nicely with the rest of gorm).

-) You can now chain select calls.  This could be useful in
conjunction with gorm's scopes functionality.
2014-11-17 07:36:26 -05:00
ryanss 62b447bc9a Create tables with fields in same order as defined in struct 2014-11-17 07:36:26 -05:00
Jinzhu b1c2a22646 Remove unnecessary ToSnake 2014-11-12 10:23:54 +08:00
Paolo Galeone da3e74ba6f Add support for signed and unsigned integer types as primary key type 2014-11-12 10:09:06 +08:00
deoxxa c041e53612 fix query generation for one-to-one relations 2014-11-06 10:52:23 +11: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