Commit Graph

224 Commits

Author SHA1 Message Date
Jinzhu e9684db42a Show error message if not using addressable value for auto migration 2014-11-25 13:44:14 +08: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
Jinzhu a29ac54e48 Limit condition should not be inherited by following queries 2014-10-28 17:18:11 +08:00
Jinzhu 5eeff5d38f Fix some errors for the mssql support pull request 2014-09-19 21:49:04 +08:00
Joel Trost 6b7d0879c5 Ran gofmt and removed panic statements
Unnecessary panics in create_test and delete_test removed
2014-09-16 14:24:55 -07:00
Joel Trost f79e1a2ef6 GORM support for MSSQL, passes all tests 2014-09-16 14:21:35 -07:00
Jinzhu b2360c11da Add Fields for embedded struct 2014-08-30 21:42:35 +08:00
Robert B Gordon 94aa843830 Add HasTable() 2014-08-29 00:28:54 -05: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
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 9012c9ea09 Add Set, Get method for DB 2014-08-20 16:25:01 +08:00
Jinzhu 14fdbdd965 AutoMigrate accepts structs 2014-08-20 11:56:39 +08:00
Shirou WAKAYAMA 5ad9306146 Add DropTableIfExists. 2014-08-05 23:14:40 +09:00
Jinzhu 4d98c8c0bc Specify database dialect when open database, fixes #169 2014-08-05 10:34:41 +08:00
Benjamin Ruston d699c85486 Use fmt.Errorf 2014-08-04 19:54:05 +01:00
Jinzhu 90106d82c5 Export Relationship 2014-07-31 14:38:16 +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 ba95de5c50 Rename relations to associations 2014-07-30 14:30:21 +08:00
Jinzhu d7400c2df4 Don't sort by primary key if it doesn't exist in First/Last 2014-07-29 18:29:03 +08:00
Jinzhu 2bffb43138 Write stub code for Many2Many 2014-07-29 17:28:10 +08:00
Jinzhu 11dc47587c Support inline condition when Delete 2014-07-24 18:30:12 +08:00
Jinzhu 1c1df2318c Fix exception for FirstOrCreate when search condition is nil 2014-07-01 15:55:19 +08:00
Jinzhu 6c5b95e2b2 Return query error in FirstOrInit and FirstOrCreate 2014-06-23 20:10:54 +08:00
Vladimir Garvardt d2e526bc2d db.Create() for force insert with predefined primary key 2014-06-12 00:51:43 +04:00
Jinzhu f32fa0cb6e Add RowsAffected for DB 2014-06-05 17:58:14 +08:00
Vladimir Garvardt d1dc0ccbef AddUniqueIndex 2014-06-01 02:35:56 +04:00
Vladimir Garvardt cdce84fd1a AddIndex for multiple columns 2014-06-01 02:26:17 +04:00
Jinzhu 288c8e37af Merge branch 'sunfmin-master'
Conflicts:
	main.go
2014-04-25 07:23:26 +08:00
Jinzhu a46d149579 remove package dialect for easier contribution 2014-04-25 07:20:23 +08:00
Felix Sun 1ff3c79c75 When multiple databases have the same table name and column names, automigrate doesn't work 2014-04-25 00:39:38 +08:00
Jinzhu fd3ce3b39a Add method to close gorm db connection 2014-04-24 10:55:17 +08:00
Xavier Dumesnil 5e62e7fdad Include scope.TableName() in ORDER statement for First() & Last() 2014-04-10 16:29:09 +02:00
Timothy Stranex 42448cb5d6 Add DB.CommonDB() instead of DB.Tx(), as discussed in the PR thread. 2014-03-17 12:08:44 +02:00
Timothy Stranex a336f51444 Add DB.Tx() method to provice access to the underlying sql.Tx instance. 2014-03-16 18:24:32 +02:00
Jinzhu 2c33502503 Add tests for updated_at will be updated when update value with Assign 2014-02-18 10:03:14 +08:00
Jinzhu e2897f0c9b clone callback when call Callback 2014-01-29 10:25:58 +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 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 7a99f37ba4 Make exec works with plugin system 2014-01-28 10:29:12 +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 549d7a8af2 make first, last works with plugin system 2014-01-28 09:30:30 +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 23feade663 use callback update when save 2014-01-27 11:25:55 +08:00
Jinzhu ee6a6827a8 implement callback shared 2014-01-27 08:26:59 +08:00
Jinzhu 7b8e91377b callback create.go 2014-01-26 21:23:53 +08:00
Jinzhu 8dd7b4ed91 make callback create works 2014-01-26 19:36:15 +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
Jinzhu 6bb7c8b744 Add callback.go 2014-01-23 16:43:39 +08:00
Jinzhu 66bfcec72e Initalize default logger when initalize DB 2014-01-04 15:32:44 +08:00
Jinzhu ccae2f0345 Update DB struct for plugin system 2014-01-04 15:08:00 +08:00
Jinzhu 4125526ef6 Improve Logger 2014-01-03 19:23:41 +08:00
Jinzhu 8010616e89 Add method Raw and Scan 2014-01-03 18:14:51 +08:00
Jinzhu 690cb1430c Show errors except RecordNotFound error by default for easy debug 2013-12-17 20:42:08 +08:00
Jinzhu e6a2273114 Remove method SetPool() in favour of sql package's builtin method, Use
it like this `db.DB().SetMaxIdleConns(10)`

So gorm don't need to care about compatibility problems, and you could
use latest `database/sql` features from latest releases without waiting gorm's support
2013-12-04 14:33:35 +08:00
Jinzhu 90a4581a7f Use method DB() to get database connection handle 2013-12-04 14:29:44 +08:00
Jinzhu 0e2bef7006 Add Method RecordNotFound() 2013-11-24 11:29:37 +08:00
Jinzhu 660ee1ed73 Add Method NewRecord 2013-11-23 21:38:31 +08:00
Jinzhu 87f493d080 Add Scopes Support 2013-11-18 14:35:44 +08:00
Jinzhu 1a2eef181a Add Method UpdateColumn, UpdateColumns 2013-11-17 21:44:11 +08:00
Jinzhu 5411291173 Rename UpdateColumn to ModifyColumn 2013-11-17 20:38:43 +08:00
Jinzhu c62568c089 Make Exec possible to accepts arguments 2013-11-17 16:47:39 +08:00
Jinzhu b41f2957fb Add method Group, Having 2013-11-17 13:29:01 +08:00
Jinzhu 094a546815 Update README 2013-11-17 12:02:22 +08:00
Jinzhu bf1db1534e Use channel to make gorm faster 2013-11-17 09:50:34 +08:00
Jinzhu 0ad707b410 Yay, all tests passed 2013-11-16 18:42:47 +08:00
Jinzhu 38f7ecdf15 Better do.go 2013-11-16 17:39:09 +08:00
Jinzhu e0d3100294 Should copy DB when save, update, delete 2013-11-16 14:15:33 +08:00
Jinzhu c3d2746912 Copy search when init do 2013-11-16 13:19:29 +08:00
Jinzhu cc03f438ef Add Update, Updates back 2013-11-16 12:19:35 +08:00
Jinzhu ea67d1d377 Move non-public DB method to private.go 2013-11-16 11:41:31 +08:00
Jinzhu 3cfa19b761 Move all chain method to main.go 2013-11-16 11:36:30 +08:00
Jinzhu 85109e104e Rename some interfaces 2013-11-16 08:15:21 +08:00
Jinzhu 2d85c30fde Add search condition 2013-11-15 22:29:42 +08:00
Jinzhu 5ded927a9a change method NewDialect to New 2013-11-15 19:43:45 +08:00
Jinzhu c1c13129f1 Finish dialects 2013-11-14 19:09:27 +08:00
Jinzhu ac4b2e2a42 Initalize dialects 2013-11-14 17:35:23 +08:00
Jinzhu c03999a44e Add Tag Support 2013-11-14 00:03:31 +08:00
Jinzhu 32562b5537 Better Log support 2013-11-11 15:48:31 +08:00
Jinzhu 1c49c4ef85 Don't copy unnecessary variables 2013-11-11 13:40:35 +08:00
Jinzhu d550315548 Add Transaction Support 2013-11-11 13:16:24 +08:00
Jinzhu 9bc11d6637 Support Logger 2013-11-11 11:11:49 +08:00
Jinzhu 9e762a9a30 Try to add logger 2013-11-11 09:10:16 +08:00
Jinzhu 874856a592 Cleanup unused code 2013-11-10 23:07:09 +08:00
Jinzhu 0cb1c1ba32 Remove unnecessary field 2013-11-10 22:29:53 +08:00
Jinzhu 5da8461161 auto migrate 2013-11-07 09:09:54 +08:00
Jinzhu da6ffd52dd Add Method SingularTable 2013-11-06 21:43:41 +08:00
Jinzhu e78c10690b Add Last Method, And update README for method First, Find 2013-11-04 17:58:56 +08:00
Jinzhu 49cfb0d4a0 Add DropTable 2013-11-01 15:01:39 +08:00
Jinzhu 724ffec683 Add Method Not 2013-10-31 17:31:00 +08:00
Jinzhu 549c7450ea Make it easy when only change one field with Attr, Assign 2013-10-31 12:59:04 +08:00
Jinzhu 688e992266 Add method Assign 2013-10-31 08:15:19 +08:00
Jinzhu 0a47d75870 Add support for Attrs 2013-10-30 15:21:58 +08:00
Jinzhu 94bd2eb8d5 Add Debug Mode 2013-10-29 19:39:59 +08:00
Jinzhu 2e84f3b216 Initialize method FirstOrInit, FirstOrCreate 2013-10-29 18:02:28 +08:00
Jinzhu 7e5dc40f6f Don't do real delete when deleted_at column exist 2013-10-29 09:01:48 +08:00
Jinzhu bc785a9173 Cleanup code 2013-10-29 08:41:07 +08:00
Jinzhu 2a20e551ed Possible to specify table name 2013-10-28 20:27:25 +08:00
Jinzhu 2388dacfe3 Hidden unnecessary public fields 2013-10-28 12:52:06 +08:00
Jinzhu 5de6416354 Clean up dependencies 2013-10-28 12:46:50 +08:00
Jinzhu c412729570 Update README 2013-10-28 10:10:02 +08:00
Jinzhu f74c9015a1 Inline which condition for first/find 2013-10-27 20:54:56 +08:00
Jinzhu f892a52cad Refact 2013-10-27 19:47:15 +08:00
Jinzhu 244b27a6a0 Refact main.go 2013-10-27 08:06:01 +08:00
Jinzhu 9d2f7650be Refact tests 2013-10-27 07:38:08 +08:00
Jinzhu 96128cdec3 Fix where chain 2013-10-27 02:53:31 +08:00
Jinzhu 3c68efc94a Support create table with struct 2013-10-26 17:30:34 +08:00
Jinzhu 70315e8fed Create table method 2013-10-26 15:47:30 +08:00
Jinzhu 540345f552 Add more dummy code for orm.go 2013-10-26 07:14:57 +08:00
Jinzhu 7f9d486d5a Initialize the tests 2013-10-25 22:31:56 +08:00
Jinzhu 7f73480a35 Build basic architecture 2013-10-25 18:31:10 +08:00
Jinzhu 2d6fa2c96d init files 2013-10-25 18:04:48 +08:00