Commit Graph

59 Commits

Author SHA1 Message Date
Jinzhu d7ef7871a4 Fix tests 2019-03-10 19:33:49 +08:00
gstvg 282f11af19 Support only preloading (#1926)
* add support for only preloading relations on an already populated model

* Update callback_query.go

comments
2018-09-10 06:52:32 +08:00
Jinzhu 77eb925ea0 Refactor preloading many2many for auto preload 2018-02-10 00:07:16 +08:00
Geoff Baskwill ec72a4cb6b Call Query callback chain when preloading many2many (#1622)
When using `Preload` on a `many2many` association, the
`Query` callback chain was not being called. This made
it difficult to write a plugin that could reliably get
called regardless of how objects were being queried.

Now `handleManyToManyPreload` will call the `Query`
callback chain for each object that is retrieved by
following the association.

Since the data has already been read by the
`handleManyToManyPreload` method, a new scope setting
called `gorm:skip_queryCallback` is set to `true` before
calling the callbacks. Callbacks can check for the
presence of this setting if they should not be run; the
default `queryCallback` is an example of this case.

Fixes jinzhu/gorm#1621.
2018-02-09 23:22:53 +08:00
tux-mind 1eb3a5ae97 DB errors over NotFound
Errors comings from DB have higher priority than logic ones
2017-04-16 21:15:51 +02:00
Jinzhu c730b30a78 Fix "Unsupported destination" error when value is pointer of pointer 2017-02-07 08:32:18 +08:00
Jinzhu 23abd03a95 Add error if exists after parse query results 2017-02-02 22:29:41 +08:00
Jinzhu 846a2d401a Fix scan columns with same name 2016-03-10 17:13:48 +08:00
Jinzhu d08894cd69 Rename test files 2016-03-08 22:00:15 +08:00
Jinzhu ec110657da Refactor based on golint 2016-03-07 17:49:55 +08:00
Jinzhu 3055bad1e8 scope.Fields() return slice of *Field 2016-03-07 14:25:41 +08:00
Jinzhu 2522f03c1f Set identity insert on after create transaction, close #841 2016-03-05 19:22:33 +08:00
Jinzhu b054f235b9 Fix query with extra option 2016-02-15 19:42:49 +08:00
Jinzhu c9dfd80959 Support extra options for inserting, querying, deleting, updating SQL, close #721, #769 2016-02-15 19:36:48 +08:00
Jinzhu 94fb0dd1d4 Merge branch 'master' into v1.0_dev 2016-02-14 21:49:14 +08:00
Jinzhu aa45da1542 Preload first before run after find 2016-02-14 21:47:13 +08:00
Jinzhu 07773cc367 Keep refactoring on callbacks 2016-01-17 20:51:11 +08:00
Jinzhu 317e1a9a48 Keep refactoring callbacks 2016-01-17 16:28:32 +08:00
Jinzhu 31366f388f Remove uncessary method CallMethodWithErrorCheck for Scope 2016-01-17 16:14:14 +08:00
Jinzhu de73d30503 Refactor callbacks 2016-01-17 15:30:42 +08:00
Jinzhu 8e2aaa92c9 Rename Callbacks to Callback 2016-01-16 21:55:00 +08:00
Jinzhu f1237e4fe9 Refactor Callback 2016-01-16 21:46:57 +08:00
Jinzhu d9229c5a7b Extract method Scan from rows 2016-01-13 16:53:11 +08:00
Jinzhu d53f5cf6dd Rename scope.Trace to trace 2016-01-13 16:00:08 +08:00
Jinzhu 4c1a78bab7 Don't query all columns out from database after create, but only those has default value 2015-12-04 18:41:28 +08:00
Jinzhu fa86433142 Overwrite initiliazed slices as empty slices 2015-08-01 09:09:09 +08:00
Jinzhu 2d802c3445 Overwrite slice results with Find 2015-06-24 13:56:30 +08:00
Jinzhu c2dda88f9a Use Get to replace InstanceGet 2015-05-19 16:58:33 +08:00
Femaref fa696b0e2f Quote the primary column name when doing queries
Postgresql requires certain column names to be quoted.
When unquoted, all upper-case characters will be converted to lower-case,
and column names like 'typeID' will result in a query on 'typeid'.
2015-04-26 16:34:52 +02:00
Jinzhu ef4299b398 Add RowQuery callback 2015-04-17 18:27:20 +08:00
Jinzhu 7d16055a5d Don't use instance setting for order_by_primary_key 2015-03-23 11:07:39 +08:00
Jinzhu 6e5d46bf37 Refactor Search API 2015-03-12 14:47:07 +08:00
Jinzhu 9f2959959b Add error if query destination is not supported 2015-03-12 12:11:38 +08:00
Jinzhu 4c815fd2cc Add add limit 1 for Find automatically 2015-03-12 12:01:53 +08:00
Jinzhu ce72988e96 Refactoring API for plugin system 2015-02-26 14:40:30 +08:00
Jinzhu 83ee11e184 Don't call callbacks if has error 2015-02-24 16:28:15 +08:00
Jinzhu 38cbff9c79 Refactor Associations 2015-02-17 20:19:47 +08:00
Jinzhu 73b6f0eace Linting according to golint 2015-02-17 08:34:01 +08:00
Jinzhu dd635a17c2 Preload belongs_to, has_one, has_many relations 2015-02-11 13:43:53 +08:00
Jinzhu 3b784c37c4 First try for the Preload feature 2015-02-11 09:47:10 +08:00
Jinzhu 1888335b6e Add RowsAffected for query 2015-01-28 11:16:33 +08:00
Jinzhu 726b3b8c9f Don't raise scan error on column index 2015-01-19 15:50:21 +08:00
Jinzhu 0219fb1cc0 Don't raise error if no record found when find all 2014-12-19 11:50:34 +08:00
Jinzhu facd84deec Quote table name when order by primary key 2014-09-13 16:11:49 +08:00
Jinzhu d806b7084f Pass anonymous struct tests 2014-08-30 21:42:35 +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 3af077ac46 Refact First, Last to make it possible to reset table name in Plugin 2014-08-25 16:41:26 +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 0d3085393e Add IndirectValue for Scope 2014-07-30 14:58:00 +08:00