Commit graph

244 commits

Author SHA1 Message Date
Aaron L
f40688cfe3 Refactor Update & Insert tests.
- Added additional checking to statements for drivers that support a
  number of results affected.
- Changed the way we keep imports around for compare values
2016-08-13 23:38:41 -07:00
Aaron L
efa1fbb80a Big refactor of generated code
- Stop generating helper functions for each model
- Move Insert/Update/Upsert query generation helpers to strmangle
- Add tests for query generation helpers
- Delete a lot of the Insert/Upsert tests that test the query generation
  helpers.
- Use tx for more of the tests.
2016-08-13 21:21:26 -07:00
Aaron L
8a7a9a35e8 Fix the last bits of problems with auto inc pkey 2016-08-13 16:34:02 -07:00
Aaron L
944303f2f5 Properly abstract LastInsertID 2016-08-13 16:34:02 -07:00
Aaron L
ef03225024 Add primary key column gen 2016-08-13 16:34:02 -07:00
Aaron L
ab88d8511d Move string set operations to strmangle
- Delete MakeDBName (unused)
- Rename HasElement to SetInclude
2016-08-13 16:34:02 -07:00
Patrick O'brien
160c6ff0f0 Begin the pain 2016-08-13 16:34:02 -07:00
Aaron L
1875bac7cf Correct improper detection of one-to-one 2016-08-13 15:33:54 -07:00
Patrick O'brien
641a433a2d Fix query in insert 2016-08-14 06:35:43 +10:00
Patrick O'brien
3fb6c1aa48 Convert Delete object to use Exec 2016-08-14 05:07:38 +10:00
Aaron L
2b4508b228 Pass through sql.ErrNoRows for .Find() too 2016-08-13 11:56:59 -07:00
Aaron L
956157d057 Pass through no-rows errors to the user for .One() 2016-08-13 11:42:28 -07:00
Aaron L
1ac3853d3c Refactor some awkward looking bits 2016-08-13 11:39:03 -07:00
Aaron L
5360d3094e Use errors package all over the project
In general:
errors.New("thing") -> errors.New
fmt.Errorf("thing %s", arg) -> errors.Errorf
fmt.Errorf("thing %v", err) -> errors.Wrap
fmt.Errorf("thing %s %v", arg, err) -> errors.Wrapf
2016-08-13 11:37:16 -07:00
Patrick O'brien
8831e8a4b9 Fix debug outputs for all templates 2016-08-14 02:58:18 +10:00
Patrick O'brien
7ae9af702f Add debug output to Exists 2016-08-14 02:19:36 +10:00
Patrick O'brien
6c299c82cb Fix formatting errors 2016-08-14 02:16:10 +10:00
Patrick O'brien
ae198fd759 Fix formatting 2016-08-14 02:07:28 +10:00
Patrick O'brien
d92a439c54 Modify postgres query to get is_unique for indexes
* Remove unused SnakeCase function
* Fix formatting bug in relationship structs
2016-08-13 17:30:55 +10:00
Patrick O'brien
18029166c0 Add FilterColumnsByUnique, finish UpdateAll slice
* Add FilterColumnsByUnique
* Fix lots of broken tests
* Made CompareVals less stupid

Note: UpdateAll tests still broken because Unique
is not being fetched correctly for INDEX types,
it is only working for UNIQUE constraints.
2016-08-11 22:26:49 +10:00
Patrick O'brien
e3f319346f Finish UpdateAll query builder
* Add modifiers to delete builder
* Update golden file tests
* Add startAt to whereClause
2016-08-11 18:23:47 +10:00
Patrick O'brien
99b292b1ee Update query builder to make queries readable
* Finish DeleteAll for slice and query
* Fixed some formatting and comments
2016-08-09 20:19:42 +10:00
Patrick O'brien
2ece7d14f6 Clean up helpers, remove duplicate funcs
* Refactor DeleteAll for slice
2016-08-09 15:57:54 +10:00
Aaron L
8e3c1d41da GenerateParamFlags -> Placeholders
- Rewrite Placeholders to not use as much wizardry and magnetism
2016-08-08 20:19:26 -07:00
Aaron L
a98e474c9c Refactor WhereMultiple into new WhereClause 2016-08-08 19:33:10 -07:00
Aaron L
db747cccfe Fix fallout of whereclause change 2016-08-08 17:36:37 -07:00
Aaron L
7c65598f17 Fix spacing problem. 2016-08-08 17:36:37 -07:00
Patrick O'brien
b9fc5e4080 Fix ReloadAll 0 value primary key collisions 2016-08-09 10:34:21 +10:00
Patrick O'brien
fa8e431349 Add ReloadAll for ObjectSlice
* Fix RandomizeSlice bug overwriting blacklisted columns
* Add GroupAt param to param flags generator
2016-08-08 23:30:29 +10:00
Patrick O'brien
a073752df2 Remove duplicates from insert whitelist 2016-08-08 16:59:54 +10:00
Aaron L
1c7ad18ab1 Fix previous edit mistake 2016-08-07 23:37:05 -07:00
Aaron L
44cf647d05 Rewrite Find using normal sql 2016-08-07 23:36:11 -07:00
Aaron L
444153222b Use the new bind in all templates 2016-08-07 23:07:15 -07:00
Aaron L
1236072f05 Fix struct tags for bind 2016-08-07 18:07:37 -07:00
Aaron L
307fe4919a Add parsing routine for SQL from/join statements
- Bonus: Add yaml/toml struct tags for models
2016-08-05 23:51:13 -07:00
Aaron L
2d608c4e17 Correct the problems with to_one 2016-08-05 22:19:49 -07:00
Patrick O'brien
b1b0607123 Fix template errors 2016-08-05 15:04:00 +10:00
Patrick O'brien
feb85a2a44 Finish upsert and upsert tests
* Fix find bug in query generator
2016-08-05 12:59:40 +10:00
Patrick O'brien
8a3a08baa0 Finish upsert, most of upsert tests
* Fix Upsert hooks
* Rename singleton template files
2016-08-05 00:26:39 +10:00
Patrick O'brien
70b2dcfbb2 Boilerplate for upsert 2016-08-05 00:25:35 +10:00
Patrick O'brien
358dac851f Add upsert file and renamed file numbers 2016-08-05 00:22:53 +10:00
Aaron L
535c86bca0 Use query mods for to_many 2016-08-03 22:36:08 -07:00
Aaron L
a1b14f4eae Fix struct tag generation.
- Clean up template
2016-08-03 22:34:46 -07:00
Patrick O'brien
ed2c5e407d Fix insert and update whitelist generators 2016-08-04 13:55:25 +10:00
Aaron L
b8b44eba98 Document generateInsertColumns properly. 2016-08-03 20:52:43 -07:00
Aaron L
7abeba46f9 Redo the update inference docs 2016-08-03 20:38:23 -07:00
Aaron L
4a90e726db Fixed up documentation. 2016-08-03 20:23:55 -07:00
Patrick O'brien
964f367700 Add Exists feature 2016-08-03 20:23:43 +10:00
Patrick O'brien
afedc92224 Change Enforced to Validated 2016-08-03 14:22:32 +10:00
Patrick O'brien
c7c0fe5c0d Add provision for enforced types, eg uuid
* Add enforced to column data
* Add enforced list to driver
* Fix bug in TitleCase (now uses regexp)
* Fix broken zero-value enforced type inserts by using RandomizeEnforcedStruct
2016-08-03 12:05:05 +10:00
Patrick O'brien
775c5ba369 Fix IdentQuote bug, add Reload helpers 2016-08-02 20:00:00 +10:00
Aaron L
9a5742eeea Use query generation for relationship_to_one
- This allows the use of query mods
2016-08-01 20:38:32 -07:00
Patrick O'brien
2d732c727a Remove X funcs and add G funcs 2016-08-01 15:10:10 +10:00
Aaron L
b447018220 Rename ReverseArgs -> ReverseInserts
- Remove debug comment
2016-07-17 17:52:55 -07:00
Aaron L
d4170806f5 Produce true one_to_one relationships.
- Generating code & test for one_to_one by calling existing to_one
  templates with the reversed texts function output as input.
- Add a section to reverse the order of the function inserts.
2016-07-17 17:50:01 -07:00
Aaron L
1a53eab27f Rewrite to_one template as a sub-template
- This allows us to use the sub-template in other templates.
2016-07-16 23:57:08 -07:00
Aaron L
fc5bbc3e2e Use the cached relationship information 2016-07-16 13:02:35 -07:00
Patrick O'brien
488e203c0b Change objectSlice to be exported (ObjectSlice) 2016-07-17 00:15:14 +10:00
Patrick O'brien
916b7026dc Fix relationship to one bug 2016-07-16 21:40:50 +10:00
Patrick O'brien
f45d137f5f Added panic functions
* Fixed linter errors
* Added lots of missing comments
* Fixed broken boil tests
* Skipped unfinished functions instead of error
2016-07-16 21:22:57 +10:00
Patrick O'brien
4fcfcfe24c Finished hook tests
* Fixed hook bug
2016-07-16 01:21:09 +10:00
Patrick O'brien
05aa289167 Merge branch 'master' of github.com:nullbio/sqlboiler 2016-07-15 20:17:15 +10:00
Patrick O'brien
81883d5f75 Finish update tests
* Add SetMerge helper
* Add quotes around all column names in statements
* Fix blacklist bug in RandomizeStruct
* Split up update helper
2016-07-15 20:14:47 +10:00
Aaron L
bbf40bea53 Fix to_many relationship bug.
- IDs were being inserted incorrectly causing an sql key duplicate error
  instead of being inserted into the join table.
2016-07-14 23:28:33 -07:00
Aaron L
6ddef6095e Rewrite to_one relationships with text helpers.
- Fix a gross if statement.
2016-07-14 21:48:59 -07:00
Aaron L
f1df86ab9e Finish to_many base test case (no join table) 2016-07-13 22:34:18 -07:00
Patrick O'brien
c424780458 Refactored and finished insert tests 2016-07-14 15:09:05 +10:00
Patrick O'brien
4036786b6a Got insert testing in a better state
* Split up insert function for testing
* Add DBType to global state
* Move test reflection helpers to testing.go
* Add incremental seed to randomizeField to avoid duplicate constraint
  error messages
* Fixed Viper SSL default bug
* Fixed pgpass SSL inclusion bug
* Add MakeStringMap strmangle helper
* Change test errors from error to skip
2016-07-14 02:51:40 +10:00
Aaron L
fe93ccffeb Make to_many use the X paradigm. 2016-07-11 15:23:47 -07:00
Aaron L
2e3830053d Make to_one relationships use the X paradigm. 2016-07-09 10:14:07 -07:00
Aaron L
d7adb7006e Rename IsNullable -> Nullable
- Skip insert test
- Fix whitespacing issue
2016-07-09 10:13:35 -07:00
Patrick O'brien
08d168605f Added more insert test, added comments
* Added IsZeroValue helper
2016-07-08 01:59:07 +10:00
Patrick O'brien
0275677216 Merge branch 'master' of github.com:nullbio/sqlboiler 2016-07-06 16:04:54 +10:00
Patrick O'brien
7a0b84848f Add more tests to insert template tests
* Add helpers to assist with template tests
* Change null []byte from string to []byte
2016-07-06 16:02:35 +10:00
Aaron L
0df0f964e7 Finish to_many for join tables. 2016-07-01 16:20:59 -07:00
Aaron L
c731661261 Use new templating features in all templates
- Add another check for join tables in the to_many relationships stuff.
- Fix a number of quoting bugs in the templates.
2016-06-26 23:59:27 -07:00
Aaron L
0d07bb4e67 First implementation of to_many relations. 2016-06-26 23:56:45 -07:00
Aaron L
c6740529df Add more template functions.
- Fix some quoting nonsense in another template.
2016-06-26 23:56:45 -07:00
Aaron L
49d3260dcd Fix where clause so it outputs quotes.
- Fix templates that this change broke
2016-06-26 23:56:45 -07:00
Aaron L
fee1231813 Push strmangle refactoring through everything. 2016-06-22 23:48:49 -07:00
Aaron L
84a160f3a4 Start of the to_many relationships. 2016-06-22 22:03:05 -07:00
Aaron L
4d0742b6f3 Fix up a number more template errors from refactor
- Add quoteWrap function to help where some of the old helpers were
  covering.
2016-06-19 22:58:14 -07:00
Aaron L
119e683952 Use extensive piping throughout the templates
- Haskell ftw
2016-06-19 22:22:50 -07:00
Aaron L
82115b24e0 Rename templates to enforce sane ordering. 2016-06-19 16:29:59 -07:00
Aaron L
f46c2c5337 Add relationship "to_one" template.
- Temporarily add some new helper functions, going to clean these all
  up in favor of pipes
- Annotate a couple of super weird methods
- Fix a printf verb for err
2016-06-19 16:01:22 -07:00
Patrick O'brien
1508d85cb6 Finish Bind test, renamed querymods package
* Rename querymods qs package to qm
* Refactor comparing values in template tests to remove redundancy
2016-06-15 00:01:28 +10:00
Aaron L
8757c8a184 Refactor entire project :D
- Move most files to root
- Remove cmds directory in favor of cmd directory with binary
- Remove all cobra from main
2016-06-11 18:25:00 -07:00
Patrick O'brien
b5409c7332 Fixed assign defaultRun bug, fixed "all" order
* Organized files better
* More comments
2016-02-29 19:39:49 +10:00
Patrick O'brien
20720b2cc0 Changed SQLBoiler init method
* Now uses maps to load commands
* Map for custom run handlers
* Map for template functions
* Streamlined cmd creation process
2016-02-29 15:49:26 +10:00
Patrick O'brien
25fa09cf93 Added initTemplates, moved tpls folder
* Moved all template functions to shared
2016-02-29 13:30:54 +10:00
Patrick O'brien
403951940f Added comments to all tpl statements
* Added new statements
* Modified existing statements
* (TODO: FINISH STATEMENT IMPLEMENTATIONS)
2016-02-29 12:52:17 +10:00
Patrick O'brien
69adb1a552 Finished delete command 2016-02-23 22:51:49 +10:00
Patrick O'brien
5d679aa0bc Finished select and insert commands 2016-02-23 22:38:24 +10:00
Patrick O'brien
b43f9c63d8 Struct generation complete, pipes to stdout
* Database driver config & flag complete
* Table flag complete, will use all tables if non specified
2016-02-23 18:27:32 +10:00