Skip to content
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

Insert Default #266

Merged
merged 4 commits into from
Apr 30, 2022
Merged

Insert Default #266

merged 4 commits into from
Apr 30, 2022

Conversation

billy1624
Copy link
Member

@billy1624 billy1624 commented Mar 8, 2022

PR Info

Adds

  • Insert default
  • InsertStatement::or_default_values method

References

@billy1624 billy1624 self-assigned this Mar 8, 2022
@billy1624 billy1624 marked this pull request as ready for review March 8, 2022 11:37
@billy1624 billy1624 requested a review from tyt2y3 March 8, 2022 11:37
@tyt2y3
Copy link
Member

tyt2y3 commented Mar 13, 2022

Okay I am just being curious, does MySQL/Pg/SQLite actually allow multiple DEFAULT VALUES?
I mean inserting multiple rows in one statement

@@ -58,4 +58,8 @@ impl QueryBuilder for MysqlQueryBuilder {
) {
// MySQL doesn't support declaring materialization in SQL for with query.
}

fn insert_default_keyword(&self) -> &str {
"VALUES (DEFAULT)"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it does seem like it's only for inserting one row

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will insert only one row with default values

@ikrivosheev
Copy link
Member

@billy1624 can you resolve the merge conflict?

@tyt2y3
Copy link
Member

tyt2y3 commented Apr 22, 2022

MySQL/Pg/SQLite actually allow multiple DEFAULT VALUES?

I think we need to investigate this and if it's valid SQL supported by at least 2 DB we should implement accordingly

@billy1624
Copy link
Member Author

@tyt2y3
Copy link
Member

tyt2y3 commented Apr 26, 2022

Well then may be we should further work on it

@billy1624
Copy link
Member Author

Well then may be we should further work on it

I have added a method, or_default_values_many, for inserting multiple rows with default values

Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billy1624 thank you! Some comments.

tests/postgres/query.rs Outdated Show resolved Hide resolved
tests/postgres/query.rs Outdated Show resolved Hide resolved
Copy link
Member

@ikrivosheev ikrivosheev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@billy1624 LGTM!

@tyt2y3
Copy link
Member

tyt2y3 commented Apr 30, 2022

Cool. I think the important piece is how we are implementing the backend

@tyt2y3 tyt2y3 merged commit d58481b into master Apr 30, 2022
@tyt2y3 tyt2y3 deleted the insert-default branch April 30, 2022 02:00
tyt2y3 pushed a commit that referenced this pull request May 9, 2022
* Insert default

* Insert multiple rows with default values

* Refactoring
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Insert default values behaviour
3 participants