Commit graph

169 commits

Author SHA1 Message Date
Aaron L
f23092d4a5 Move randomize things 2016-08-17 23:57:46 -07:00
Aaron L
9c2a4d7852 Merge branch 'eager' 2016-08-17 23:17:13 -07:00
Patrick O'brien
3ae0b8a0d6 Fix randomize struct not ignoring boil - tag 2016-08-18 14:21:08 +10:00
Aaron L
3ecb8f96c0 Fix the loadRelationships code & test 2016-08-17 18:52:42 -07:00
Patrick O'brien
8806e76d9f Nearly finished relationship bind helper
* If only reflection would be nice
2016-08-18 03:56:00 +10:00
Patrick O'brien
94d36d7bf7 Begin IN implementation 2016-08-17 15:19:23 +10:00
Aaron L
7ce4146854 Add GetSliceValues to help clean up eager loads 2016-08-16 22:14:07 -07:00
Aaron L
80c08ce20a Make Bind act on a sql.Rows
- This change was important to be able to call boil.Bind() from other
  contexts than a query. We don't use query mods everywhere, and we
  shouldn't. This allows us to use the bind independent of that.
2016-08-16 22:14:07 -07:00
Patrick O'brien
9d6de3ba68 Remove test file for query mods 2016-08-16 22:41:43 +10:00
Patrick O'brien
a54725f0fc Add more tests
* Fix broken readme link
2016-08-16 01:46:41 +10:00
Patrick O'brien
aaa567c7df Add panic condition 2016-08-15 22:43:10 +10:00
Patrick O'brien
7be2f9f2bc Add RandomizeStruct test 2016-08-15 15:00:26 +10:00
Aaron L
6e18bbd5f1 Remove random from generation 2016-08-14 21:13:24 -07:00
Aaron L
1caa8afa73 Change seed to start at a random value.
- Insert at least some randomness.
2016-08-14 20:44:59 -07:00
Aaron L
490cdef5bc Force local seeds for randomize struct.
- Global data is actually a bad idea
2016-08-14 20:12:01 -07:00
Aaron L
81433cfaf4 Not freeing rows objects. 2016-08-14 18:36:22 -07:00
Patrick O'brien
75e28d3f5b Refactor RandomizeField
* Fix randomize arg in relationship helper
* Fix param name for RandomizeStruct
2016-08-15 01:32:57 +10:00
Aaron L
6a040bc11c Fix wording of testing 2016-08-14 03:07:23 -07:00
Aaron L
ff981ee885 Make counters atomic 2016-08-14 02:31:51 -07:00
Aaron L
8188648a11 Delete randomize slice 2016-08-14 02:11:32 -07:00
Aaron L
b34a8e3212 Destruct ugly code bits from boil package 2016-08-14 00:25:30 -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
ab88d8511d Move string set operations to strmangle
- Delete MakeDBName (unused)
- Rename HasElement to SetInclude
2016-08-13 16:34:02 -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
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
39eebe7a91 Fix broken u u i d 2016-08-14 04:26:11 +10:00
Patrick O'brien
f823dfc757 Fix broken exists test for UUID PRIMARY KEYS 2016-08-14 03:42:58 +10:00
Patrick O'brien
ffa751b1a7 Add escaping question marks for args
* Add thorough ConvertQuestionMarks test
2016-08-14 00:54:46 +10:00
Patrick O'brien
8ccfdc38df Add BufPool to query_builders.go 2016-08-14 00:20:13 +10:00
Patrick O'brien
d2862ef281 Fix broken tests due to spacing 2016-08-13 22:34:46 +10:00
Patrick O'brien
7517ad3ced Fix ? conversion to $x for having and join args 2016-08-13 03:59:50 +10:00
Patrick O'brien
4b27cea3a6 Add join with where using args test 2016-08-13 03:28:46 +10:00
Patrick O'brien
4571184b7d Add args to Having query mod
* Add more thorough golden tests
* Fix bug in update column ordering, now uses sort
2016-08-13 03:08:09 +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
c3f8cff117 Add Or and And query mods, add ? placeholders
* Update whereClause builder to support Or and parentheses
* ? placeholders are now used instead of $1, $2 etc for where clauses.
* Update the whereClause test to add more tests and fix broken ones.
* Fix broken golden test files.
2016-08-11 16:44:15 +10:00
Patrick O'brien
af1b647fb4 Remove Or query mod, add builder whereClause test
* Add fixture tests/golden files
2016-08-09 22:29:59 +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
33286e648a Update repo to add vattle org paths 2016-08-09 17:59:30 +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
89ec1cfdb7 Delete useless duplicate method. 2016-08-08 17:36:37 -07: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
Aaron L
0b7e6fc507 Seperator -> Separator 2016-08-08 00:42:13 -07:00
Aaron L
f6d113a5ef GroupBy and Having work now 2016-08-08 00:28:01 -07:00
Aaron L
d999c7b4d7 Fix failing test.
- Let's not be smart about renames in Bind(), just do the normal thing
  and bind to whatever the user's asked us to.
2016-08-08 00:20:19 -07:00
Aaron L
44cf647d05 Rewrite Find using normal sql 2016-08-07 23:36:11 -07:00
Aaron L
989bece6b3 Restore Exec/One/All 2016-08-07 18:16:34 -07:00
Aaron L
b3ba8462d9 Fix inner join query mod 2016-08-07 18:12:13 -07:00
Aaron L
113754d38b Finish bind tests
- One test failing because lack of idMap usage
2016-08-07 18:07:37 -07:00
Aaron L
ee2b4e7990 Rewrite bind.
- Break bind down into separate functions
- Implement naming inference in bind for multiple tables
- Make One and All take the same code path mostly
2016-08-07 18:07:37 -07:00
Aaron L
1ba2333658 Add test for a query with writeStars 2016-08-07 18:07:37 -07:00
Aaron L
6596868cb8 Change join structure to truly support any join
- Also normalize the "," vs ", " in query generation
2016-08-07 18:07:37 -07:00
Aaron L
162746526c Add min/max/sum/avg to the query gen 2016-08-07 18:07:37 -07:00
Aaron L
5541b4dce9 Reorganize things before tearing apart 2016-08-07 18:07:37 -07:00
Aaron L
8298da6f48 Refactor GetStructPointers 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
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
8dbf322754 Add Update back for UpdateAll 2016-08-05 00:26:39 +10:00
Patrick O'brien
70b2dcfbb2 Boilerplate for upsert 2016-08-05 00:25:35 +10:00
Aaron L
f98ff568fb Remove unused fields 2016-08-03 22:44:57 -07:00
Aaron L
9503acaf8e Missed some compilation errors 2016-08-03 22:28:04 -07:00
Aaron L
1a1a025b58 Add append versions of boil query helpers 2016-08-03 22:22:17 -07:00
Aaron L
48e14f4fd8 Add multiple from statements. 2016-08-03 21:50:26 -07: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
39fe91f2cb Add RandomizeEnforcedStruct
* Fix broken Select QM test
2016-08-03 10:53:34 +10:00
Patrick O'brien
775c5ba369 Fix IdentQuote bug, add Reload helpers 2016-08-02 20:00:00 +10:00
Patrick O'brien
fb8540af1a Change to IdentQuote, add IdentQuote to Select QM 2016-08-02 13:25:02 +10:00
Aaron L
757aaf3a4d Fix tests for uuid string types 2016-07-31 21:56:49 -07:00
Aaron L
fd7cb01b89 Add an order by query 2016-07-31 21:05:03 -07:00
Patrick O'brien
edecf1b704 Add "count as" query fixture 2016-08-01 13:06:51 +10:00
Aaron L
b8c28c7cf8 Add offset and limit generation 2016-07-31 19:21:06 -07:00
Patrick O'brien
ba5034b7ee Fix things 2016-07-19 15:36:26 +10:00
Patrick O'brien
f713e041ad Add sql query mod, finish or querymod
* Add comments to kill lint errors
2016-07-19 14:07:12 +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
a559738d59 Added boil error helpers 2016-07-16 15:38:51 +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
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
7863284e61 Rename Creator interface. 2016-07-09 09:31:50 -07:00
Patrick O'brien
013b3ae0f8 Added more reflect helpers 2016-07-09 02:39:36 +10: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
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
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
Patrick O'brien
0bb847c0da Refactor Where clause, add to insert builder
* Fix Find template comparison, replace DeepEqual
2016-06-12 07:55:23 -07:00
Aaron L
d97e826265 Fix some documentation and ugly constant placement 2016-06-11 15:09:46 -07:00
Patrick O'brien
98e0b1f2ad Fixed unit test comparison bug for Null types
* Set randomized field values to zero value for objects with Valid false
  This ensures the types will match the zero values returned from the
  db.

* Reverted make statements to proper initialization format
2016-06-11 18:30:56 +10:00
Patrick O'brien
ca9d296f99 Change randomizeField decimals to X.X precision
* This was done to reduce conflicts with DB constraints on decimal cols
* when comparing data objects in the unit tests
2016-06-11 01:18:01 +10:00
Patrick O'brien
8cc14ce48f Change RandomizeStruct float to single decimal
* Now only uses single decimal precision (0.0-0.9) to avoid conflicting
* with any database decimal constraints and causing data mismatch.
2016-06-11 00:57:59 +10:00
Patrick O'brien
e99bb09856 Added finisher template tests
* Added randDate function
2016-06-11 00:22:08 +10:00
Patrick O'brien
9ede42c577 Added args to delete query builder
* Fixed delete query builder WHERE bug
* Finished Delete template tests
2016-06-10 15:20:26 +10:00
Patrick O'brien
ecb20cca4a Added RandomizeSlice function 2016-06-10 12:09:48 +10:00
Patrick O'brien
1e412cec74 Added COUNT function to select query builder 2016-06-10 09:43:45 +10:00
Patrick O'brien
7aba7104a5 Fix null package imports, finish Bind
* Fix randomizeStruct time randomization
* Defer close sql.Rows
* Begin Delete test template
2016-06-08 15:45:34 +10:00
Patrick O'brien
a20574110c Added SortByKeys to insert 2016-06-07 17:08:00 +10:00
Patrick O'brien
d0b494600e Fixed BuildQuery test 2016-06-07 16:45:06 +10:00
Patrick O'brien
8a7926664c Removed null for null-extended
* Fixed broken RandomizeStruct test
2016-06-07 16:42:19 +10:00
Patrick O'brien
37a333f6ff Added SortByKeys
* Fixed slice allocations in strmangle helpers
* Removed duplicate commaList function
2016-06-07 16:21:00 +10:00
Patrick O'brien
4ad069f64d Finish BindAll implementation 2016-06-07 14:38:17 +10:00