-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: replace "id" with model.IDField #604
Conversation
@@ -350,8 +350,8 @@ func (c *Connection) Update(model interface{}, excludeColumns ...string) error { | |||
} | |||
|
|||
tn := m.TableName() | |||
cols := columns.ForStructWithAlias(model, tn, m.As) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This uses the outer model
instead of the iteration model. Not sure if this was a bug or intended behavior but I assume it should have been the current model within the iteration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this has had problems in the past where TableName()
had to be defined on the slice type or something similar. I agree that this should be m
and not model
. Can you please add a failing test case for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like it actually does not matter. It is not possible to pass a interface{}
slice, because that breaks reflection everywhere. So only slices of a struct type are allowed, and it also makes sense to only allow them. Therefore it resembles the exact same behavior as before in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know too little about reflection to judge this statement, so I would prefer reverting this to the original behavior just in case this breaks something somewhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, reverted
cols.Add(columnNames...) | ||
|
||
} else { | ||
cols = columns.ForStructWithAlias(model, tn, m.As) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, model
was the outer model.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #604 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Could you please add some tests to cover these changes?
c1 := columns.ForStruct(&foo{}, "foo") | ||
c2 := columns.ForStruct(&foos{}, "foo") | ||
c1 := columns.ForStruct(&foo{}, "foo", "id") | ||
c2 := columns.ForStruct(&foos{}, "foo", "id") | ||
r.Equal(c1.String(), c2.String()) | ||
} | ||
|
||
func Test_Columns_Basics(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is missing two tests:
- PK is
id
and the ID field can not be written but can be read. - PK is
notid
and the ID field ca be written and read butnotid
can not be written.
have a test where the PK is not"id"
and you are not able to update that particular PK
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added cases but not everything is possible like you expect, see #556
@@ -350,8 +350,8 @@ func (c *Connection) Update(model interface{}, excludeColumns ...string) error { | |||
} | |||
|
|||
tn := m.TableName() | |||
cols := columns.ForStructWithAlias(model, tn, m.As) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think this has had problems in the past where TableName()
had to be defined on the slice type or something similar. I agree that this should be m
and not model
. Can you please add a failing test case for this?
cols.Add(columnNames...) | ||
|
||
} else { | ||
cols = columns.ForStructWithAlias(model, tn, m.As) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
modelType = modelType.Elem() | ||
} | ||
|
||
if modelType.Kind() == reflect.String { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can model be a string?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, there are several test cases for that, e.g. https://github.com/gobuffalo/pop/blob/master/executors_test.go#L1506
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com>
* Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com>
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu>
* v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu>
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com>
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com>
* feat: arm64 binary * v6.0.2 (#704) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> * play time * chore: updates * chore: reset formatting Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com>
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number * fix: associations for embedded fields * test: add other fields to duplicate type, because of some kind of query builder cache * feat: implement UpdateQuery This commit introduces a new function, UpdateQuery, that enables updating all rows matched by a query. It can be used for conditional updates. * feat: allow customizing the time used for CreatedAt/UpdatedAt * feat: allow using SQLite without built tag via include (#662) * preparing go1.18 support (package specific workflow) * feat: darwin arm64 binary (#690) * feat: arm64 binary * v6.0.2 (#704) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> * play time * chore: updates * chore: reset formatting Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding release-env in the gitignore * task: its release-env * task: adding .release-env to the release-dry-run make * task: changing the order of release steps * task:changing the token Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: Grant Zvolsky <grant@zvolsky.org> Co-authored-by: Andrew Hobson <ahobson@truss.works> Co-authored-by: Yonghwan SO <scinix@gmail.com> Co-authored-by: Joey Freeland <30938344+jfreeland@users.noreply.github.com>
* fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number * fix: associations for embedded fields * test: add other fields to duplicate type, because of some kind of query builder cache * feat: implement UpdateQuery This commit introduces a new function, UpdateQuery, that enables updating all rows matched by a query. It can be used for conditional updates. * feat: allow customizing the time used for CreatedAt/UpdatedAt * feat: allow using SQLite without built tag via include (#662) * preparing go1.18 support (package specific workflow) * feat: darwin arm64 binary (#690) * feat: arm64 binary * v6.0.2 (#704) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Export WhereID, Alias, WhereNamedID (#637) This patch export some model convenience functions which are useful when constructing queries outside of pop: custom updates, deletes, inserts, ... Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * fix: log model values everywhere (#656) Some SQL logs were missing the values as argument. This adds all places * Add delete to query builder (#658) This allows writing delete queries without knowing the exact primary key or for composite keys. `Destroy` only allows to delete by primary key, but there are many cases where you want to delete multiple rows or by some other query than the ID. See #29 * Sort down migrations (#657) Basically, just reversing the up migration order does not work, as that puts "all" migrations before specific ones. Therefore, I added implemented the proper `Less` function for down migrations explicitly. Related #533 Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> * Preserve eager information when validating models (#664) (#665) Co-authored-by: Karl Haas <karl.haas@coditects.com> * Migrate from packr to fs (#667) * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * Migrate from packr to fs * Migrate to v6 * Use old build tags * Update error handling * Fix error after rebase * Fix error handling * Fix filenames for embed Go 1.16 usage Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Task merging master (#669) * v5.3.4 (#644) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Latest from master (#620) * Latest from development (#617) * fix: improve model ID field customization (#604) Updates places where `"id"` was hardcoded instead of using `model.IDField()`. * Ensure uninitialized map is initialized when unmarshaling json Add tests for this scenario * exclude migration_table_name from connection string * add test for OptionsString * Add support for pointer FKs when preloading a belongs_to association (#602) * feat: support context-aware tablenames (#614) This patch adds a feature which enables pop to pass down the connection context to the model's TableName() function by implementing TableName(ctx context.Context) string. The context can be used to dynamically generate tablenames which can be important for prefixed or generic tables and other use cases. * Bump pg deps (#616) * Reset to development * bumping pgx and pgconn versions Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * adding goreleaser syntaz (#619) Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> * Resolve issues in UPDATE and DELETE when using schemas (#618) * Resolve MySQL issues and improve test migrations * Bump CockroachDB to maintained and supported versions Version 2.1 has reached EoL in 2019 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use `PaginatorPageKey` and `PaginatorPerPageKey` variables (#615) * update pagination_test * Pass Time structure into timestamp update functions. (#625) Closes #624 * Allow nullable JSONB and resolve MySQL regression (#639) * Allow passing args to `Order` (#630) * Added connection maximum idle time configuration (#635) This PR add the possibility to configure the connection maximum idle time (https://golang.org/pkg/database/sql/#DB.SetConnMaxIdleTime). Closes #632 BREAKING CHANGE: Requires Go 1.15 from now on. * Bump sqlite to 3.35.4 / 1.14.7 (#642) * Update pg, pgx, sqlx (#643) - `jackc/pgx` to version `v4.11.0`. - `jmoiron/sqlx` to version`v1.3.3` - `lib/pq` to version`v1.10.1` * Fix Inner has many associations when passing on multiple arguments (#633) * Fix Inner has many associations when passing on multiple arguments for inner fields * Fix broken tests * clean up extractFieldAndInnerFields function Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> * Remove many to many TX condition for EagerPreload (#645) * Remove the need to use Tx when loading many to many associations * replace TX access to create a new tx.Store.Transaction() object * Added fix/tests for has_many with pointer foreign key (#647) Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Updating Pgx (#660) * adding goreleaser syntaz * updating pgx now really * tidying Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> * Replace removed command The command has been removed from the CLI. This patch introduces a new mechanism to reliably dump the SQL schema for CockroachDB. * Resolve `EagerPreload` panic caused for pointer references Resolves a panic where `EagerPreload` tried to set `reflect.Struct` for a `reflect.Pointer` on 1.. associations. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve `EagerPreload` panic caused by NullUUID Resolves a panic where `EagerPreload` was trying to set UUID into NullUUID. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Support pointers in n+1 `Eager` loading Resolves an issue where n+1 eager associations would error with a double pointer in `associations.ForStruct`. Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Improve error message of associations.ForStruct Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Add test cases for `IsZeroOfUnderlyingType` Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve an obscure bug where empty structs got loaded for NULL foreign keys Closes #139 Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve association regression in finders.go Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Use dedicated migrations for preloading regression test Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix code regression Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix test code regressions Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Fix sql migration order Signed-off-by: aeneasr <3372410+aeneasr@users.noreply.github.com> * Resolve order issue in test * Ignore order when testing for nil values in test * Pass Context during exec in create. (#688) * feat: support embedded struct fields (#691) * test: use `T.TempDir` to create temporary test directory This commit replaces `ioutil.TempDir` with `t.TempDir` in tests. The directory created by `t.TempDir` is automatically removed when the test and all its subtests complete. Prior to this commit, temporary directory created using `ioutil.TempDir` needs to be removed manually by calling `os.RemoveAll`, which is omitted in some tests. The error handling boilerplate e.g. defer func() { if err := os.RemoveAll(dir); err != nil { t.Fatal(err) } } is also tedious, but `t.TempDir` handles this for us nicely. Reference: https://pkg.go.dev/testing#T.TempDir Signed-off-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding next version number Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> * play time * chore: updates * chore: reset formatting Co-authored-by: Antonio Pagano <645522+paganotoni@users.noreply.github.com> Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> * task: adding release-env in the gitignore * task: its release-env * task: adding .release-env to the release-dry-run make * task: changing the order of release steps * task:changing the token * feature: supporting sqlite :memory: and mode=memory on the sqlite driver (#717) * feat: expose connection transactions with context and options * task: adding vscode to the ignore list Co-authored-by: Patrik <zepatrik@users.noreply.github.com> Co-authored-by: Michael Montgomery <mmontg1@gmail.com> Co-authored-by: kyrozetera <jasonhale.w@gmail.com> Co-authored-by: Reggie Riser <4960757+reggieriser@users.noreply.github.com> Co-authored-by: hackerman <3372410+aeneasr@users.noreply.github.com> Co-authored-by: Stanislas Michalak <stanislas.michalak@gmail.com> Co-authored-by: Larry M Jordan <larrymoralesjordan@gmail.com> Co-authored-by: Brian Buchholz <4773480+bhb603@users.noreply.github.com> Co-authored-by: Mike Pontillo <mpontillo@users.noreply.github.com> Co-authored-by: Benjamin Blattberg <ben.blattberg@objectrocket.com> Co-authored-by: Jonathan Duck <Duckbrain30@gmail.com> Co-authored-by: Arthur Knoepflin <arthur.knoepflin@epitech.eu> Co-authored-by: karlhaas <haaskarl81@gmail.com> Co-authored-by: Karl Haas <karl.haas@coditects.com> Co-authored-by: Matthias Fasching <fasching.matthias@gmail.com> Co-authored-by: Martin Eigenbrodt <martin.eigenbrodt@googlemail.com> Co-authored-by: Eng Zer Jun <engzerjun@gmail.com> Co-authored-by: Grant Zvolsky <grant@zvolsky.org> Co-authored-by: Andrew Hobson <ahobson@truss.works> Co-authored-by: Yonghwan SO <scinix@gmail.com> Co-authored-by: Joey Freeland <30938344+jfreeland@users.noreply.github.com>
Still found some places where
"id"
was hardcoded instead of usingmodel.IDField()
.