Servant-Software-LLC / FileBased.DataProviders

ADO.NET & EF Core Data Providers for common serializable formats (JSON, XML, and CSV) stored to disk.
2 stars 1 forks source link

Support the Boolean data type in the providers SQL syntax #22

Open DaveRMaltby opened 1 year ago

DaveRMaltby commented 1 year ago

Although it appears that we support boolean values in the data sources (for example: https://github.com/Servant-Software-LLC/ADO.NET.FileBased.DataProviders/blob/main/tests/Data.Json.Tests/Sources/Folder/employees.json#L6), if we change the INSERT statement in https://github.com/Servant-Software-LLC/ADO.NET.FileBased.DataProviders/blob/main/tests/Data.Tests.Common/InsertTests.cs#L34 to provide the literal true instead of a string quoted literal 'true', then the Irony parsing assumes that it is a simple_id and an exception occurs.

Data.Csv.Tests.FolderAsDatabase.CsvInsertTests.Insert_ShouldInsertData
   Source: CsvInsertTests.cs line 15
   Duration: 154 ms

  Message: 
    System.ArgumentOutOfRangeException : Index was out of range. Must be non-negative and less than the size of the collection. (Parameter 'index')

  Stack Trace: 
    List`1.get_Item(Int32 index)
    FileQuery.GetValue(ParseTreeNodeList x) line 91
    FileInsertQuery.<GetValues>b__1_0(ParseTreeNode x) line 16
    SelectListIterator`2.GetCount(Boolean onlyIfCheap)
    FileInsertQuery.GetValues() line 17
    FileInsert.Execute() line 43
    FileCommand.ExecuteNonQuery() line 71
    InsertTests.Insert_ShouldInsertData(Func`1 createFileConnection) line 35
    CsvInsertTests.Insert_ShouldInsertData() line 18
    RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
    MethodInvoker.Invoke(Object obj, IntPtr* args, BindingFlags invokeAttr)
DaveRMaltby commented 1 year ago

ANSI SQL as defined in SQL:1992 can be found at https://www.contrib.andrew.cmu.edu/~shadow/sql/sql1992.txt. There it describes boolean literals:

         <truth value> ::=
                TRUE
              | FALSE
              | UNKNOWN

I am not advocating that we also support the UNKNOWN literal constant. Just TRUE and FALSE.