Commit Graph

218 Commits

Author SHA1 Message Date
Jinzhu becd777b1e Fix unicode chars in SQL 2018-02-13 12:37:39 +08:00
Jinzhu 67c4280c57 Fix support embedded pointer type struct, close #1450 2018-02-13 10:00:18 +08:00
Jinzhu cfd1cc586a Add 2D array support, close #1201 2018-02-13 08:33:11 +08:00
Jinzhu 8005321a1c Allow table option when DropTable, close #1514 2018-02-12 14:49:24 +08:00
Jinzhu 30adc80edc Test customize data type for primary key 2018-02-12 13:20:55 +08:00
Jinzhu 7e2bb3d7fa Allow customize table name when creating index, close #1656 2018-02-12 11:56:51 +08:00
Jinzhu 7a8c2bbff8 Refactor build SQL condition 2018-02-12 00:06:31 +08:00
Jinzhu 86c04795b7 Port PR #1655 to Not query builder 2018-02-11 15:52:52 +08:00
andrew 8d66eb4926 fixed wrong param substitution order 2018-02-11 14:58:22 +08:00
Jinzhu 46269198a4 Refactor PR #1569 2018-02-11 13:41:46 +08:00
matematik7 36043ad905 Fix for quoted column names and add test 2018-02-11 13:11:54 +08:00
matematik7 841ea1bde5 Do not always override select on pluck 2018-02-11 13:11:54 +08:00
Jinzhu c503108f83 Refactor fix valuer 2018-02-11 12:48:08 +08:00
Viktor Nikolaiev ba3e6201c7 fixed issue with null values in where conditions 2018-02-11 09:19:57 +08:00
Viktor Nikolaiev 3b6d790e93 Made it possible to implement driver.Valuer for byte slices 2018-02-11 09:19:57 +08:00
Jinzhu fd15156d39 Fix Count in mssql for SQL with group 2018-02-11 09:16:10 +08:00
Jinzhu 85774eb9da
Merge branch 'master' into master 2018-02-10 22:25:28 +08:00
Jinzhu b2b568daa8 Add tag association_autoupdate, association_autocreate, association_save_reference support 2018-02-10 17:34:02 +08:00
Jinzhu 43dc867644 Allow save association relations w/o saving association 2018-02-10 17:34:02 +08:00
Jinzhu 89a726ce5d Move ModifyColumn implemention to Dialect 2018-02-09 22:58:34 +08:00
Jinzhu e9309d361f Fix build exception 2018-02-09 22:34:59 +08:00
Amit Yadav 0e1cb6ece9 Add support to remove foreign key constraints (#1686) 2018-02-09 22:20:26 +08:00
Jinzhu 802104cc7c Use BuildKeyName to build db's index name 2018-02-02 22:01:31 +08:00
Jinzhu 630c12b549 Refactor #1693 2018-01-31 17:14:21 +08:00
Wing Gao 26262ef9bb autoIndex should throw an error on failed 2017-11-28 13:05:48 +08:00
Horacio Duran 3a9e91ab37 Correct ModifyColumn SQL syntax. (#1614)
* Correct ModifyColumn SQL syntax.

The generated SQL for ModifyColumn was:

`ALTER TABLE "tablename" MODIFY "columname" type`

But should have been:

`ALTER TABLE "tablename" ALTER COLUMN "columname" TYPE type`

since Modify does not seem to be entirely compatible with all Engines

* Test ModifyColumn

* Skip ModifyColumnType test on incompatible DBs

Some DB Engines don't fully support alter table so we skip
when the dialect does not correspond to one of the ones that
are known to support it.
2017-09-28 22:48:21 +08:00
Code 56fffcb25b fix count() …
COUNT()函数逻辑有错误,本应该是在执行任何SQL的时候,都可以返回正确的行数。而现在复杂的SQL集合无法正确获取行数。
2017-08-29 18:50:40 +08:00
Jinzhu e5432b14d2 Add QueryExpr, thanks @ManReinsp for PR #1548 2017-08-11 18:41:04 +08:00
Ivan Valkov 2a1463811e Allow use number as column name (#1517)
* Updated scope.go to always quote when adding index

I am using numbers for column names (to be compatible with protobuf) and adding unique index to them does not work since they are not quoted. I do not see a reason to check if the column name is a string in order to quote it. Correct me if I am wrong.

* Updated the columnRegexp to include decimals

* Update scope.go
2017-07-03 21:49:54 +08:00
Jinzhu 2a041971f9 Change bind var to 24652$ to avoid possible confliction 2017-04-18 16:13:02 +08:00
Jinzhu 66d5b42ee9 Add error if exists after parse raw query results, fix #1398 2017-03-24 09:28:06 +08:00
Russ Egan 45f1a95051 Replace all use of *sql.DB with sqlCommon
Exporting sqlCommon as SQLCommon.

This allows passing alternate implementations of the database connection, or wrapping the connection with middleware.  This change didn't change any usages of the database variables.  All usages were already only using the functions defined in SQLCommon.

This does cause a breaking change in Dialect, since *sql.DB was referenced in the interface.
2017-03-14 17:02:14 -04:00
Jinzhu e4b130d2d7 Fix customize DeletedAt's column name 2017-02-01 21:33:36 +08:00
Jinzhu c62e9bcabe Query Row, Rows inside RowQuery callbacks 2017-01-15 18:03:12 +08:00
Geofrey Ernest eb0880e710 Fix *Scope.buildNotCondition
this fixes the logic of handling empty slice of int family in a query i.e something linke `[]int64{}`

This code snipped doesn't look like it was intended to be this way

```
	if reflect.ValueOf(value).Len() > 0 {
			str = fmt.Sprintf("(%v.%v NOT IN (?))", scope.QuotedTableName(), scope.Quote(primaryKey))
			clause["args"] = []interface{}{value}
		}
		return ""
```

The `return ""` is always guaranteed to be executed regardless of whether the length of value is greater than 0. I believe the intended behavior is to return  `""` when the length of value is zero.
2017-01-05 10:38:39 +03:00
Xavier Sandal 5a4dca7645 Compile regexp ahead of time
Signed-off-by: Xavier Sandal <sandalwing@sandalwing.com>
2016-12-19 22:36:13 -05:00
Jinzhu 0f2ceb5a77 Add gorm:association:source for association operations for plugins to extend GORM 2016-12-05 18:30:07 +08:00
Jinzhu eb06255b66 Skip order sql when quering with distinct 2016-12-01 16:16:20 +08:00
Jinzhu 066abcef40 Merge pull request #1132 from zardak/preload-dedupe 2016-11-10 09:33:15 +08:00
slockij e26cb8dbc4 In some cases (Error not checked, missed data) one can perform very harmful operation - global update or delete (all records)
This is to prevent it.
2016-11-04 17:54:43 +01:00
Jinzhu f2fe351aa0 Merge pull request #1243 from smacker/raw_first_last
db.Raw().First() makes wrong sql fix #1214
2016-11-03 21:45:29 +08:00
Jinzhu 4a540f3ac8 Add tag to support skip nested save for associations 2016-10-27 10:31:46 +08:00
smacker cf7fbb56d5 db.Raw().First() makes wrong sql fix #1214 2016-10-26 21:32:27 +07:00
Jinzhu 56a7d1b69e Change query's prefix table for generated conditions 2016-10-26 17:35:51 +08:00
Jinzhu 39165d4980 Refactor named value support for PolymorphicType 2016-10-07 22:19:28 +08:00
slockij 1413e55339 Add named value for PolymorphicType (to replace scope.TableName) 2016-09-28 22:44:43 +02:00
Jinzhu 041cd3dd31 Fix scan ignored fields, close #1117 2016-09-13 09:29:36 +08:00
Jinzhu 35a2a004d8 Strict select argument check for Count 2016-08-15 21:28:07 +08:00
Jinzhu 2f27f0f27f Fix TestUpdateDecodeVirtualAttributes 2016-08-14 16:13:50 +08:00
elgris fb09befb9b Adds processing of ignored fields on Update 2016-08-14 16:12:57 +08:00