Skip to content

Setting a BIT field to 1 with TVPs results in a 0 #539

@alexnixon

Description

@alexnixon
SQLServerDataTable table = new SQLServerDataTable();
table.addColumnMetadata("Wat", Types.BIT);
table.addRow(1);

This table will store a 0 into your database, because the 1 gets converted to "1" with toString, then parsed to false with Boolean.parseBoolean.

I personally disagree with SQLServerDataTable::addRow's general approach of "call toString on the argument then parse it in a lax manner". I think it would be better to:

  • Handle known types specifically, e.g. if you attempt to set a BIT field with a Byte, cast it to a Byte and handle the value
  • Handle known values specifically, e.g. allow 0, 1, true, false to set a BIT field
  • Reject unknown types and nonsense values with an exception

Metadata

Metadata

Labels

BugA bug in the driver. A high priority item that one can expect to be addressed quickly.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions