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

[SQLServer] insert bool value #437

Closed
stefaniaolivares opened this issue Dec 17, 2020 · 4 comments
Closed

[SQLServer] insert bool value #437

stefaniaolivares opened this issue Dec 17, 2020 · 4 comments
Projects

Comments

@stefaniaolivares
Copy link

Hi! I'm having trouble with inserting bool values ​​in sql server. The compiler translate bool with true or false instead of 1 or 0. How can I solve this issue?

var query = new Query(Table).AsInsert(model); var sql = SqlServerCompiler().Compile(query).ToString();

The value of the sql variable is
INSERT INTO [Table] ([IsRunning], [IsEnabled]) VALUES (false, true)

Thanks!!

@ahmad-moussawi
Copy link
Contributor

@stefaniaolivares have you tried to execute this directly in the Database?
The ToString() representation is not 100% similar to what get executed

@stefaniaolivares
Copy link
Author

Yes I tried but the query not working, maybe I'm doing something wrong.

@mzolonk
Copy link

mzolonk commented Apr 23, 2021

Your .ToString() seem to be converting the the object and not the contents of it.

Insert does work, you need to make sure that each value is either a string or 0/1

tested the insert with this code.

CREATE TABLE dbo.SomeTable(IsRunning BIT, IsEnabled BIT)
GO

INSERT dbo.SomeTable(IsRunning, IsEnabled)
VALUES('TRUE', 'FALSE')
GO

INSERT dbo.SomeTable(IsRunning, IsEnabled)
VALUES(0, 1)
GO

@ahmad-moussawi ahmad-moussawi added this to In progress in Tasks Jul 16, 2021
@ahmad-moussawi ahmad-moussawi moved this from In progress to To do in Tasks Jul 16, 2021
@ahmad-moussawi ahmad-moussawi moved this from To do to In progress in Tasks Jul 16, 2021
@ahmad-moussawi ahmad-moussawi moved this from In progress to Done in Tasks Jul 17, 2021
@ahmad-moussawi
Copy link
Contributor

#503
#510

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

No branches or pull requests

3 participants