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

Fix bulk insert with one field #710

Closed
wants to merge 9 commits into from

Conversation

podhmo
Copy link

@podhmo podhmo commented Mar 13, 2021

fix #709, #694

@podhmo podhmo marked this pull request as draft March 13, 2021 11:03
@podhmo
Copy link
Author

podhmo commented Mar 13, 2021

CI is failed, yet.

@coveralls
Copy link

coveralls commented Mar 13, 2021

Pull Request Test Coverage Report for Build 210

  • 3 of 3 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 73.894%

Totals Coverage Status
Change from base Build 194: 0.2%
Covered Lines: 1203
Relevant Lines: 1628

💛 - Coveralls

@coveralls
Copy link

Pull Request Test Coverage Report for Build 207

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.2%) to 73.894%

Totals Coverage Status
Change from base Build 194: 0.2%
Covered Lines: 1203
Relevant Lines: 1628

💛 - Coveralls

@podhmo podhmo force-pushed the fix-bulk-insert-with-one-field branch from 0f772c8 to 1c63f0a Compare March 13, 2021 13:23
_, _, now := defaultSchema.Postgres()
return fmt.Sprintf("INSERT INTO val (k, v, added_at) VALUES (:k, :v, %v)", now)
}(),
expected: "INSERT INTO val (k, v, added_at) VALUES (?, ?, now()),(?, ?, now())",
Copy link
Author

@podhmo podhmo Mar 13, 2021

Choose a reason for hiding this comment

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

Supports only no-arguments function (e.g. now()).

// extra operation
{
values: []interface{}{vs[0], vs[1]},
q: "INSERT INTO val (k,v) VALUES (:k,:v) ON DUPLICATE KEY UPDATE v = VALUES(v)",
Copy link
Author

Choose a reason for hiding this comment

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

For this, I changed the regex values ​​to start with "VALUES".

Copy link
Author

Choose a reason for hiding this comment

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

( But when this feature is used other than bulk insert (e.g. used in NamedQuery), this changes is broken )

q: "INSERT INTO val (k) VALUES (:k)",
expected: "INSERT INTO val (k) VALUES (?)",
},
{
Copy link
Author

Choose a reason for hiding this comment

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

This is the test for #709

@podhmo podhmo marked this pull request as ready for review March 13, 2021 14:59
@podhmo
Copy link
Author

podhmo commented Apr 8, 2021

#718 is almost same

@podhmo podhmo closed this Apr 8, 2021
@podhmo podhmo deleted the fix-bulk-insert-with-one-field branch April 8, 2021 12:02
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.

Bulk insert with only one colum, invalid SQL is used
2 participants