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

How can I add ON DUPLICATE KEY UPDATE to my query? #60

Closed
cozyGalvinism opened this issue Apr 12, 2018 · 3 comments
Closed

How can I add ON DUPLICATE KEY UPDATE to my query? #60

cozyGalvinism opened this issue Apr 12, 2018 · 3 comments

Comments

@cozyGalvinism
Copy link

I'm currently adding it via regex, but there's got to be a way with SqlKata, right?

@ahmad-moussawi
Copy link
Contributor

@TeamGameRevolution could you please post the full query, and how you are handling it right now ?

@cozyGalvinism
Copy link
Author

cozyGalvinism commented Apr 12, 2018

Had to switch away from regex because of some reasons.

datensaetze is a Dictionary<string, dynamic>

                    var query = new Query(quelle.Tabelle).AsInsert(datensaetze);
                    var compiler = new MySqlCompiler();
                    var qStr = compiler.Compile(query).Sql + " ON DUPLICATE KEY UPDATE " + string.Join(",", datensaetze.Select(d => $"{d.Key} = {(d.Value is string ? $"'{MySqlHelper.EscapeString(d.Value)}'" : d.Value)}"));

EDIT: Based on this: https://dev.mysql.com/doc/refman/5.7/en/insert-on-duplicate.html

@ahmad-moussawi
Copy link
Contributor

ahmad-moussawi commented Jul 15, 2018

closing, you can follow this feature on #103

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

No branches or pull requests

2 participants