-
Notifications
You must be signed in to change notification settings - Fork 132
feat: support multiple PostgreSQL transaction options #1949
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
Changes from 1 commit
1d8e6c0
8868723
2cc7ac2
6ff3a60
9e0581d
5521db4
e27c841
93f6f5a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -111,14 +111,24 @@ public Boolean convert(String value) { | |
if ("true".equalsIgnoreCase(value) | ||
|| "tru".equalsIgnoreCase(value) | ||
|| "tr".equalsIgnoreCase(value) | ||
|| "t".equalsIgnoreCase(value)) { | ||
|| "t".equalsIgnoreCase(value) | ||
|| "on".equalsIgnoreCase(value) | ||
|| "1".equalsIgnoreCase(value) | ||
|| "yes".equalsIgnoreCase(value) | ||
|| "ye".equalsIgnoreCase(value) | ||
|| "y".equalsIgnoreCase(value)) { | ||
return Boolean.TRUE; | ||
} | ||
if ("false".equalsIgnoreCase(value) | ||
|| "fals".equalsIgnoreCase(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that the values like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Strangely enough, they are. I've tried a multitude of different statements with a real PG instance. See below for the results: knut-test-db=# set default_transaction_read_only to "on";
SET
knut-test-db=# set default_transaction_read_only to tr;
SET
knut-test-db=# set default_transaction_read_only to ' true ';
ERROR: parameter "default_transaction_read_only" requires a Boolean value
knut-test-db=# set default_transaction_read_only to "true";
SET
knut-test-db=# set default_transaction_read_only to 'true';
SET
knut-test-db=# set default_transaction_read_only to ye;
SET
knut-test-db=# set default_transaction_read_only to 'ye';
SET So TLDR:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's strange because once I tested inserting boolean values in some table and the results were totally opposite :) Btw thanks for clarifying |
||
|| "fal".equalsIgnoreCase(value) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can we add support for 'ON', 'OFF', 'yes', 'no', 0 and 1 while converting the boolean values? For the Psycopg2, adding only 'ON' and 'OFF' will do but we can add 'yes', 'no', 0 and 1 to make it fully generic. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point, added for:
Including all unique prefixes (i.e. |
||
|| "fa".equalsIgnoreCase(value) | ||
|| "f".equalsIgnoreCase(value)) { | ||
|| "f".equalsIgnoreCase(value) | ||
|| "off".equalsIgnoreCase(value) | ||
|| "of".equalsIgnoreCase(value) | ||
|| "0".equalsIgnoreCase(value) | ||
|| "no".equalsIgnoreCase(value) | ||
|| "n".equalsIgnoreCase(value)) { | ||
return Boolean.FALSE; | ||
} | ||
return null; | ||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should also trim the string to consider the cases like
' true '
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(See also above). PostgreSQL does not consider that to be a valid boolean value. When the value is quoted with either single or double quotes, it may not contain any spaces.