Commit graph

252 commits

Author SHA1 Message Date
Sergey Kurt
9bafa2f158 MSSQL Upsert statement 2017-03-21 13:04:07 +03:00
Sergey Kurt
13bdda4e20 Simplified insert query 2017-03-19 18:12:06 +03:00
Sergey Kurt
d40d074320 Filtering columns with auto values 2017-03-19 12:44:15 +03:00
Sergey Kurt
12dce9d986 Auto columns in Inserts removed 2017-03-19 12:42:55 +03:00
Sergey Kurt
f3f8074833 Removed blank lines and spaces 2017-03-18 15:18:04 +03:00
Sergey Kurt
b1b0249898 New line at end of file 2017-03-16 11:01:49 +03:00
Sergey Kurt
8de60ee26a Update and Insert for columns with autogenerated values 2017-03-16 10:54:55 +03:00
Sergey Kurt
e943c37a99 Update and Insert only for columns without autogenerated 2017-03-16 10:26:05 +03:00
Sergey Kurt
4c2062caee Fixed code generation for Update and Reload 2017-03-15 19:35:44 +03:00
Sergey Kurt
f45f98ef03 Fixed placeholders 2017-03-15 19:13:20 +03:00
Sergey Kurt
ad15668462 Fixed code generation 2017-03-15 19:04:13 +03:00
Sergey Kurt
51e9961f0a Fixed OUTPUT values on Insert 2017-03-14 18:06:33 +03:00
Sergey Kurt
a48e5f7f82 MS SQL compatible query for RETURNING clause 2017-03-14 16:52:54 +03:00
Sergey Kurt
aa01f21b5c Pass UseTopClause flag into the Dialect object 2017-03-14 13:59:05 +03:00
Sergey Kurt
ed6dad7eed MS SQL compatible query for checks if the row exists 2017-03-14 13:53:35 +03:00
Sergey Kurt
83d90f3f28 Fixed quote symbols order 2017-03-14 13:48:38 +03:00
Sergey Kurt
e00ea60679 Initial MSSQL support 2017-03-13 12:55:26 +03:00
Aaron L
8f96ba35d6 Allow insertion of only-defaulted tables
- Tables that are only comprised of default values and have nothing
  passed into them on insertion will no longer generate syntax errors.
2017-03-01 18:18:47 -08:00
Aaron L
a5cb765403 Ensure created_at isn't updated when unnecessary
- When we build the update whitelist (when the user doesn't provide one)
  we simply say that the whitelist is all columns except pkeys. The
  reason we do this is because sqlboiler doesn't support dirty tracking
  and if you want to update just a few fields, it's easier to just
  explicitly pass a whitelist when you update. However, in the case of
  created_at - it's a field that's usually managed by us and so we
  should not be updating it unless a user explicitly requests it via the
  whitelist. So if the whitelist is empty we prune that column now if it
  exists from the auto-created whitelist.
- The user also reported that upsert has the same fate, but the logic is
  somewhat different there. It expects that there's a value for
  created_at or it assumes that one needs to be created. There's no
  more magic we can do around this one unfortunately. Upsert is a
  mythical beast that doesn't play as nicely with our model, so users
  will just have to be more careful.
- Fix #106
2017-02-24 22:52:09 -08:00
Aaron L
8aa4e2148c Use _ to avoid reserved words in func args
- Fix #107
2017-02-24 22:27:05 -08:00
Aaron L
59c238539d Attach all eagerly loaded models in to-one
- The problem here is that due to the nature of the relationship and the
  way the loop was set up it was possible to miss some relationships:

A _ C
 \_ D

B _ E
 \_ F

Since we looped over A and B and did a break when we found something to
attach it to (in this example A would find C) it would break. What we
should be looping through is CDEF and finding a home for each one.

Did the same change in to_one though it doesn't matter since it's
one-to-one.

to-many is untouched because it's already looping over CDEF and finding
a home for it because the relationship is reversed.

- Fix #98
2017-01-26 22:06:47 -08:00
Aaron L
c02a2f0c20 Fix null dereference 2017-01-24 23:04:59 -08:00
Aaron L
936df65ebc Fix ToManyRemoveOp
- This would generate a bad query when run, also the test was failing
  for this same reason and once enabled it was trivial to fix.
2017-01-24 22:45:20 -08:00
Aaron L
c33bb479a1 Fix postgres placeholders for to-many.RemoveX
- Help fix #97
2017-01-24 18:57:45 -08:00
Aaron L
61ab7e254a Add missing function variants for setops.
- Fix #87
2017-01-09 21:06:47 -08:00
Aaron L
22f7a45847 Ignore empty errors on postgres upsert fail
- Postgres's behavior when there is no update is that there is an
  ErrNoRows thrown back, which we can safely ignore since the only time
  this can happen in postgres's case is under this circumstance since
  there's no race unlike the mysql upsert code.
- Fix #84
2017-01-05 21:31:43 -08:00
Aaron L
4ae9336538 Fix bug in ToManySetOpsAdd and impure join tables
- This is a bug that manifests itself a bunch with our update code where
  you cannot actually use the update method to update a key since it
  uses the values on the struct to both update the values and find the
  object to update but in this operation the key must have two different
  values.
2017-01-04 20:31:29 -08:00
Aaron L
b6b16b8dd6 Fix combining relationship query mods
- Fix #67
2016-11-15 21:57:21 -08:00
Aaron L
ede97dea5b Add enum const generation
- Make postgres name its enums
- Add way to filter columns by whether or not they're an enum
- Split parsing of enums into name & values
- Add strmangle check functions: IsEnumNormal, ShouldTitleCaseEnum
- Add new strmangle enum functions to template test
- Implement a set type called "once" inside the templates so that we can
  ensure certain things only generate one time via some unique name.
2016-11-11 01:06:30 -08:00
Aaron L
3046214fb6 Ensure that relationship structs aren't clobbered
- There was no thought put in if a relationship struct already existed
  when it went to be used a second time so it was being clobbered.
- Fix #39
2016-11-08 18:25:15 -08:00
Aaron L
2c534361e1 When .LoadX gets called, create R structs
- Fix #51
- This is a waste of allocations, but in general makes for a much nicer
  user interface.
2016-09-29 19:32:43 -07:00
Aaron L
32290d9236 Fix mysql LastInsertId() 2016-09-24 16:10:26 -07:00
Aaron L
5f394a4f69 Fix one-to-one setops 2016-09-24 14:34:31 -07:00
Aaron L
09ed5709e5 Fix template spacing with new output
- The old templates used to output \n\n after each run, with the
  previous changes this is no longer the case and as such the templates
  all must be formatted correctly.
2016-09-24 00:52:18 -07:00
Aaron L
e9eda8fa1b Revert "Copy to_one_setops into one_to_one_setops"
This reverts commit e157a59714.
2016-09-24 00:23:17 -07:00
Patrick O'brien
e157a59714 Copy to_one_setops into one_to_one_setops 2016-09-24 12:42:39 +10:00
Aaron L
fa2202abb2 Fix SetOp for half join tables 2016-09-22 23:17:54 -07:00
Aaron L
0530ba9227 Rename $rel -> $txt for consistency 2016-09-22 21:49:50 -07:00
Aaron L
d438ce5fc1 Remove a couple seldom used vars 2016-09-22 00:21:12 -07:00
Aaron L
093db148e3 Change text helpers to use refactored func naming
- This cleans up the function naming so it's easier to follow in all
  cases. Provides better tests for the same.
2016-09-22 00:21:12 -07:00
Aaron L
b0cdc29c61 Remove unused template variables 2016-09-20 21:56:06 -07:00
Aaron L
cbb7041748 Fix #43 in a slightly different way. 2016-09-20 21:22:35 -07:00
Aaron L
79a228e297 Fixed some lint errors where spacing got messed up 2016-09-20 21:18:15 -07:00
Aaron L
b1344befe2 Change 'if eq .NoHooks false' -> 'if not .NoHooks' 2016-09-20 21:08:19 -07:00
Aaron L
5ba6769134 Remove unuseful text helper variable 2016-09-20 21:08:19 -07:00
Patrick O'brien
522cb6824c Fix receiver lint errs 2016-09-21 13:38:14 +10:00
Patrick O'brien
0a1a12cd0a Primary key only tables are now handled adequately 2016-09-20 18:05:33 +10:00
Patrick O'brien
9102327b1c Remove rowsaffected as 0 error 2016-09-20 13:20:33 +10:00
Patrick O'brien
fdeecbf106 Fix insert and randomize errors, fix time.Time
* MySQL requires timeParsing enabled
* Update readme to reflect this requirement
2016-09-19 15:22:32 +10:00
Aaron L
a164540276 Remove temp files 2016-09-18 17:45:29 -07:00