Conversation
A custom operation converted its value without the quote information, so 'sku_is == "001"' gave the operation the int 1. A quoted value now skips the null, boolean, and number conversions. A quoted value in the date format of the grammar or a quoted guid still converts, as the docs show. Other quoted values, for example "4.5", stay strings. BREAKING CHANGE: a custom operation gets a quoted number, boolean, or "null" value as a string. A custom operation that casts a quoted value, for example (int)value for "10", throws InvalidCastException. Send the value without quotes to get a number, a boolean, or null.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR keeps a quoted value for a custom operation as a string. This is a breaking change. It is one of the six breaking changes that were removed from #114 so that main stays compatible with v1.14.2.
Status: for later consideration. Do not merge this PR now. The captain decides on each breaking change separately. If this change is accepted, it needs a major version, or the opt-in setting below.
Old behavior (v1.14.2 and main)
The value for a custom operation goes through
ConvertStringToBasicTypewithout the quote information.intor adecimal."true"becomes abool."null"becomesnull.New behavior
A quoted value skips the null, boolean, and number conversions, so it stays a
string. A quoted value in the date format of the grammar and a quoted guid still convert, as the docs show. An unquoted value converts as before.Example
The custom operation is
x.Sku == (string)value. Proof from theverify-querykitharness. Pancakes hasSku001.InvalidCastException(the operation gets theintvalue1)r."Sku" = 1::text)r."Sku" = '001'::text)An unquoted number still converts.
total_stock_above == 20returns Beef Stew on both targets, with> 20::int.After this change, a custom operation that casts a quoted value, for example
(int)valuefor"10", throwsInvalidCastException.Justification
Quotes are the only way that a client can say "this value is text". Everywhere else in the grammar, a quoted value is a string. The custom operation path ignores the quotes, so a client cannot send a code, a SKU, or a postal code with leading zeros. The client also cannot send the literal text "true" or "null".
The fix makes custom operations obey the same rule as the rest of the grammar. A consumer that wants a number can send it without quotes.
Migration and opt-in alternative
KeepQuotedValuesAsStrings(). The setting can keep the v1.14.2 default until the next major version. This PR does not add the setting.Tests
custom_operation_keeps_quoted_value_as_stringandcustom_operation_converts_unquoted_number_and_quoted_date.custom_operation_keeps_quoted_value_as_string.dotnet test: 352 unit tests and 269 integration tests pass.