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

Using Raw Literals in Update #354

Closed
arakis opened this issue Mar 26, 2020 · 2 comments
Closed

Using Raw Literals in Update #354

arakis opened this issue Mar 26, 2020 · 2 comments

Comments

@arakis
Copy link

arakis commented Mar 26, 2020

I'm using the pure Sql builder (for sql server compiler). No Execution.

It seems to be impossible to build such statement:

UPDATE table SET column = @column

Again, i cannot use classic DB Parameters like "?" or something else, because we use our own SQL execution environment. We need the pure SQL-Statement with a "@var"-Literal.

I tried the following:

            var query = new Query("testtable");
            query.AsUpdate(new string[] { "abc" }, new object[] { new UnsafeLiteral("@abc") });

Without success. But with AsInsert, it works(!). Here are the results:

INSERT INTO [table] ([column]) VALUES (@column)
UPDATE [table] SET [column] = 'SqlKata.UnsafeLiteral'

By the way, you should move the Attributes (ColumnAttribute, ...) into another namespace, so they will not conflict with System.ObjectModel.Annotations.Schema. And even Dapper tries to float the namespace with a new ColumnAttribute, if using Dapper.Contrib. So, there's a lot of conflict potential.

@ahmad-moussawi
Copy link
Contributor

@arakis Thanks for reporting, just fixed this here is the relevant PR #355
You can get the latest version from the nightly builds for now.

@ahmad-moussawi
Copy link
Contributor

Available now on the latest package.

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