Commit graph

217 commits

Author SHA1 Message Date
Aaron L
1facccacc1 Fix an edge case for MySQL
- This patch removes auto-generation of queries that have the pattern
  COUNT(tablename.*) which is a syntax error in mysql.
2016-09-13 00:48:14 -07:00
Aaron L
b1e8816d42 Fix update all 2016-09-12 23:49:18 -07:00
Aaron L
912693a124 Update parameter generation for mysql 2016-09-12 23:28:23 -07:00
Aaron L
37a05de380 Fix a mistake in the insert query 2016-09-11 23:50:11 -07:00
Aaron L
8392a4ba2a Fix quoting throughout templates
- Use "" style strings for all templates
- Attach a Quote and SchemaTable that understand escaped quotes so we
  can use "" style strings without repercussion.
- Make SchemaTable use escaped quotes
- Remove schemaTable from the templates in favor of .SchemaTable
2016-09-11 23:50:11 -07:00
Patrick O'brien
793522650c Add lq, rq, and indexplaceholders args everywhere 2016-09-10 05:15:50 +10:00
Patrick O'brien
419f2760c7 Change quotes to bytes 2016-09-10 03:30:46 +10:00
Patrick O'brien
9e6a3d5ee3 Add quote dialects 2016-09-10 03:14:18 +10:00
Patrick O'brien
ac02f7d2e0 Fix broken relationship templates by adding schema 2016-09-09 22:31:51 +10:00
Patrick O'brien
1c8a9d2e39 Add schema feature to everything (except rels)
* Add strmangle SchemaTable helper
2016-09-09 07:23:10 +10:00
Patrick O'brien
4e8191b8dd Add struct tags flag 2016-09-04 23:44:54 +10:00
Aaron L
22f67ab4ed Make sure to only write to cache when needed 2016-09-03 23:46:21 -07:00
Aaron L
ecfa35350c Finish update optimization. 2016-09-03 22:53:42 -07:00
Aaron L
0ebccdb20a Try and fix MySQL a little bit. 2016-09-03 12:50:31 -07:00
Aaron L
acad9f7de5 Finish Insert() caching. 2016-09-03 12:47:27 -07:00
Aaron L
793306d749 Fit caching in to insert. 2016-09-03 12:24:18 -07:00
Aaron L
e1bfd9d0da Remove TitleCases from NonZeroDefaultSet 2016-09-03 11:54:23 -07:00
Aaron L
b522ab6a75 Fix spacing in setop methods. 2016-09-03 11:04:37 -07:00
Patrick O'brien
09fb8005f6 Add TitleCase cache 2016-09-02 17:55:16 +10:00
Aaron L
b101df0a24 Make sure join tables get ToMany Set/Remove 2016-09-01 23:33:18 -07:00
Patrick O'brien
4b1c934751 Remove pointers to L, not needed
* Add no-tests flag
2016-09-02 11:22:56 +10:00
Patrick O'brien
fd07a1a6a7 Move loaders off R to a new struct L 2016-09-02 11:03:59 +10:00
Aaron L
b5d3b60b3a ToOne Set Remove no longer uses ... 2016-08-31 21:38:25 -07:00
Patrick O'brien
67ae024439 Unexport Relationship struct 2016-09-01 13:33:05 +10:00
Patrick O'brien
d56e28a36d Fix Location pointer 2016-09-01 11:24:39 +10:00
Patrick O'brien
8f6191c4d2 Move buildUpsertQuery to boil 2016-09-01 11:20:16 +10:00
Patrick O'brien
87b1f90c43 Fix Find name 2016-09-01 11:16:21 +10:00
Patrick O'brien
e33da59f0b Update hook names 2016-09-01 11:12:46 +10:00
Aaron L
79d8642d8d Put setops into their final resting place. 2016-08-29 22:58:55 -07:00
Patrick O'brien
629ec8c8d0 Add hooks to eager load funcs
* Add PreserveDots text helper
* Fix bug using wrong XTitleCases name
2016-08-30 02:36:07 +10:00
Patrick O'brien
ccdfc93fee Add auto timestamps for upsert
* Add IsZero checks for auto timestamps
2016-08-29 23:23:42 +10:00
Patrick O'brien
7f24185544 Add executor to hooks 2016-08-29 23:23:42 +10:00
Aaron L
9553f462c7 Merge branch 'sets' 2016-08-28 23:29:47 -07:00
Aaron L
ae99b2a649 Finish ToManyRemove.
- Make Set test better.
2016-08-28 23:26:44 -07:00
Aaron L
d9931fe7ba Finish Set 2016-08-28 21:12:04 -07:00
Aaron L
4ba1849297 Finish ToManyAdd 2016-08-28 16:51:07 -07:00
Aaron L
4e70c9bb17 Near completion on the ToManyAdd setop 2016-08-28 16:36:49 -07:00
Aaron L
0eea12fb75 Complete removal on the remove method 2016-08-28 15:01:37 -07:00
Patrick O'brien
96d40fcfe4 Add automatic timestamps for created_at/updated_at
* Update and Insert
* Add --no-auto-timestamps flag
2016-08-29 00:12:37 +10:00
Patrick O'brien
677d45cef4 Add delete and insert hooks to templates 2016-08-28 22:16:08 +10:00
Patrick O'brien
d9ec68b76a Add afterSelectHooks to One and All finishers 2016-08-28 22:02:21 +10:00
Patrick O'brien
e2553705e1 Remove BeforeSelect hook (makes no sense) 2016-08-28 21:23:08 +10:00
Patrick O'brien
2a5630ce3e Add before/after select/delete to hooks generation
* Add tests for all hooks
2016-08-28 21:13:45 +10:00
Patrick O'brien
8aad8fc479 Rename before/after Create hook to Insert hook 2016-08-28 20:54:46 +10:00
Patrick O'brien
95ff24b918 Add --no-hooks feature 2016-08-28 20:48:50 +10:00
Aaron L
947081c579 Rename ReverseInserts -> OneToOne
- Fix bug & failing test
- Skip WIP test
2016-08-28 00:27:50 -07:00
Aaron L
625dee4648 Fix documentation.
- Fix test failure for ToOneSet
2016-08-28 00:06:33 -07:00
Patrick O'brien
09cdb7a652 Fix SQL (takes exec now)
* Add SQLG
* Update templates using SQL
2016-08-28 14:51:03 +10:00
Aaron L
bc71147282 WIP - Trying to fix bugs 2016-08-27 19:10:46 -07:00
Aaron L
f6206ea6b7 Use better errors in setops 2016-08-27 12:13:15 -07:00
Aaron L
ea22d3656c Add more text helpers for ToMany. 2016-08-27 12:00:42 -07:00
Aaron L
1887f23ca5 Finish ToOneSet
- Replace the custom update that actually set every model's relationship
  to the same thing with a real update method so we get logging & hooks
2016-08-26 23:36:57 -07:00
Aaron L
9db43ae3ad Finish ToOneSet 2016-08-26 22:43:50 -07:00
Aaron L
c1962eb7ac Get all the tests running properly 2016-08-26 22:04:49 -07:00
Aaron L
f489e22ab4 Rename Loaded -> R 2016-08-26 21:40:29 -07:00
Aaron L
dc49fa4d59 Align some stuff properly
- Begin tests
2016-08-26 07:59:28 -07:00
Aaron L
6ad467c259 Started relationship set operations 2016-08-25 23:50:45 -07:00
Aaron L
28e485603a Add fast path for binding by caching TitleCase 2016-08-23 23:20:41 -07:00
Aaron L
d130354890 Fix eager loading, off-by-one pointer 2016-08-23 22:07:51 -07:00
Aaron L
509fe44f4e Rename Relationships struct to Loaded 2016-08-22 21:54:02 -07:00
Patrick O'brien
c61ff2aa46 Fix some formatting bugs of generated code 2016-08-21 16:28:47 +10:00
Patrick O'brien
0c44af51a8 Fix name conflict bug in find
* Add more tests to test schema
2016-08-21 16:03:51 +10:00
Patrick O'brien
cd7e45efaa Fix bugs for table only containing composite pkey
* Add more tables to test schema
* Add string slice match helper
2016-08-21 15:44:49 +10:00
Aaron L
c04e0d003a Make relationships only return query objects. 2016-08-18 00:19:15 -07:00
Aaron L
2567a60a25 Rename some files to keep sanity 2016-08-17 23:48:37 -07:00
Aaron L
453858d026 Put the templates in their proper place 2016-08-17 23:26:17 -07:00
Aaron L
92c4e7f8f3 Support many_to_many eager loading properly
- Reorder the where statement in to_many to match eager loading.
2016-08-17 23:09:54 -07:00
Aaron L
fb198cc92c Looking like to_many eager load is done
- Fix to_many join table query
- Fix testing output
- Add debug logging
2016-08-16 22:14:07 -07:00
Aaron L
756281f9fb WIP Debugging eager loading 2016-08-16 22:14:07 -07:00
Aaron L
932f14d26c Fix up some bits in eager load to_many 2016-08-16 22:14:07 -07:00
Aaron L
eae23ae42b Add eager loading for to_many
- Needs tests
2016-08-16 22:14:07 -07:00
Aaron L
d25712f929 Change entire project tests. 2016-08-14 01:58:36 -07:00
Aaron L
180fbb0b8c Remove swaths of metadata for tables in templates 2016-08-13 23:50:40 -07:00
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