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

Ability to pass raw string expressions in insert/delete statements #221

Closed
ghost opened this issue Mar 19, 2019 · 3 comments
Closed

Ability to pass raw string expressions in insert/delete statements #221

ghost opened this issue Mar 19, 2019 · 3 comments

Comments

@ghost
Copy link

ghost commented Mar 19, 2019

I'm using SqlKata to generate non-parameterized Oracle insert statements by using ToString() on Compile() output.

This works well, but I want dates to be inserted with Oracle's TO_DATE function.

So I convert my .Net DateTime to a string, e.g. "TO_DATE('2019/03/19 09:03:47', 'yyyy/mm/dd hh24:mi:ss')". Because it's a string, SqlKata wraps it in single quotes, which doesn't work in Oracle.

Can we have a way to not wrap some strings in quotes?

@ahmad-moussawi
Copy link
Contributor

It's not supported now, if insert into select could be an option you can use the Insert(columns, query)overload.

var select = new Query("AnyTable").SelectRaw("1 as Id, TODATE('2019/03/19 09:03:47') as Date");
var query = db.Query("TableToInsert").AsInsert(new [] {"name", "date"}, select );

check:
https://sqlkata.com/docs/execution/update#insert-from-existing-query
https://docs.oracle.com/cd/E17952_01/mysql-5.6-en/insert-select.html

@ghost
Copy link
Author

ghost commented Mar 19, 2019

Thanks Ahmad. Unfortunately the insert does not include a select.

@ahmad-moussawi ahmad-moussawi changed the title Ability to not wrap strings in single quotes on Oracle Ability to pass raw string expressions in insert/delete statements Aug 27, 2019
@ahmad-moussawi
Copy link
Contributor

using UnsafeLiteral is now an option check to #547

check this Playground example

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

1 participant