|
|
|
@@ -6,37 +6,37 @@ open System.Security.Cryptography
|
|
|
|
/// <exclude />
|
|
|
|
/// <exclude />
|
|
|
|
type Comparison =
|
|
|
|
type Comparison =
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Equals (<tt>=</tt>)</summary>
|
|
|
|
/// <summary>Equals (<c>=</c>)</summary>
|
|
|
|
| Equal of Value: obj
|
|
|
|
| Equal of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Greater Than (<tt>></tt>)</summary>
|
|
|
|
/// <summary>Greater Than (<c>></c>)</summary>
|
|
|
|
| Greater of Value: obj
|
|
|
|
| Greater of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Greater Than or Equal To (<tt>>=</tt>)</summary>
|
|
|
|
/// <summary>Greater Than or Equal To (<c>>=</c>)</summary>
|
|
|
|
| GreaterOrEqual of Value: obj
|
|
|
|
| GreaterOrEqual of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Less Than (<tt><</tt>)</summary>
|
|
|
|
/// <summary>Less Than (<c><</c>)</summary>
|
|
|
|
| Less of Value: obj
|
|
|
|
| Less of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Less Than or Equal To (<tt><=</tt>)</summary>
|
|
|
|
/// <summary>Less Than or Equal To (<c><=</c>)</summary>
|
|
|
|
| LessOrEqual of Value: obj
|
|
|
|
| LessOrEqual of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Not Equal to (<tt><></tt>)</summary>
|
|
|
|
/// <summary>Not Equal to (<c><></c>)</summary>
|
|
|
|
| NotEqual of Value: obj
|
|
|
|
| NotEqual of Value: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Between (<tt>BETWEEN</tt>)</summary>
|
|
|
|
/// <summary>Between (<c>BETWEEN</c>)</summary>
|
|
|
|
| Between of Min: obj * Max: obj
|
|
|
|
| Between of Min: obj * Max: obj
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>In (<tt>IN</tt>)</summary>
|
|
|
|
/// <summary>In (<c>IN</c>)</summary>
|
|
|
|
| In of Values: obj seq
|
|
|
|
| In of Values: obj seq
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>In Array (PostgreSQL: <tt>|?</tt>, SQLite: <tt>EXISTS / json_each / IN</tt>)</summary>
|
|
|
|
/// <summary>In Array (PostgreSQL: <c>|?</c>, SQLite: <c>EXISTS / json_each / IN</c>)</summary>
|
|
|
|
| InArray of Table: string * Values: obj seq
|
|
|
|
| InArray of Table: string * Values: obj seq
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Exists (<tt>IS NOT NULL</tt>)</summary>
|
|
|
|
/// <summary>Exists (<c>IS NOT NULL</c>)</summary>
|
|
|
|
| Exists
|
|
|
|
| Exists
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Does Not Exist (<tt>IS NULL</tt>)</summary>
|
|
|
|
/// <summary>Does Not Exist (<c>IS NULL</c>)</summary>
|
|
|
|
| NotExists
|
|
|
|
| NotExists
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>The operator SQL for this comparison</summary>
|
|
|
|
/// <summary>The operator SQL for this comparison</summary>
|
|
|
|
@@ -67,15 +67,15 @@ type Dialect =
|
|
|
|
type FieldFormat =
|
|
|
|
type FieldFormat =
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// Use <tt>->></tt> or <tt>#>></tt>; extracts a text (PostgreSQL) or SQL (SQLite) value
|
|
|
|
/// Use <c>->></c> or <c>#>></c>; extracts a text (PostgreSQL) or SQL (SQLite) value
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
| AsSql
|
|
|
|
| AsSql
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Use <tt>-></tt> or <tt>#></tt>; extracts a JSONB (PostgreSQL) or JSON (SQLite) value</summary>
|
|
|
|
/// <summary>Use <c>-></c> or <c>#></c>; extracts a JSONB (PostgreSQL) or JSON (SQLite) value</summary>
|
|
|
|
| AsJson
|
|
|
|
| AsJson
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Criteria for a field <tt>WHERE</tt> clause</summary>
|
|
|
|
/// <summary>Criteria for a field <c>WHERE</c> clause</summary>
|
|
|
|
type Field = {
|
|
|
|
type Field = {
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>The name of the field</summary>
|
|
|
|
/// <summary>The name of the field</summary>
|
|
|
|
@@ -94,83 +94,83 @@ type Field = {
|
|
|
|
/// <summary>Create a comparison against a field</summary>
|
|
|
|
/// <summary>Create a comparison against a field</summary>
|
|
|
|
/// <param name="name">The name of the field against which the comparison should be applied</param>
|
|
|
|
/// <param name="name">The name of the field against which the comparison should be applied</param>
|
|
|
|
/// <param name="comparison">The comparison for the given field</param>
|
|
|
|
/// <param name="comparison">The comparison for the given field</param>
|
|
|
|
/// <returns>A new <tt>Field</tt> instance implementing the given comparison</returns>
|
|
|
|
/// <returns>A new <c>Field</c> instance implementing the given comparison</returns>
|
|
|
|
static member Where name (comparison: Comparison) =
|
|
|
|
static member Where name (comparison: Comparison) =
|
|
|
|
{ Name = name; Comparison = comparison; ParameterName = None; Qualifier = None }
|
|
|
|
{ Name = name; Comparison = comparison; ParameterName = None; Qualifier = None }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create an equals (<tt>=</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create an equals (<c>=</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member Equal<'T> name (value: 'T) =
|
|
|
|
static member Equal<'T> name (value: 'T) =
|
|
|
|
Field.Where name (Equal value)
|
|
|
|
Field.Where name (Equal value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create an equals (<tt>=</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create an equals (<c>=</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member EQ<'T> name (value: 'T) = Field.Equal name value
|
|
|
|
static member EQ<'T> name (value: 'T) = Field.Equal name value
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a greater than (<tt>></tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a greater than (<c>></c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member Greater<'T> name (value: 'T) =
|
|
|
|
static member Greater<'T> name (value: 'T) =
|
|
|
|
Field.Where name (Greater value)
|
|
|
|
Field.Where name (Greater value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a greater than (<tt>></tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a greater than (<c>></c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member GT<'T> name (value: 'T) = Field.Greater name value
|
|
|
|
static member GT<'T> name (value: 'T) = Field.Greater name value
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a greater than or equal to (<tt>>=</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a greater than or equal to (<c>>=</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member GreaterOrEqual<'T> name (value: 'T) =
|
|
|
|
static member GreaterOrEqual<'T> name (value: 'T) =
|
|
|
|
Field.Where name (GreaterOrEqual value)
|
|
|
|
Field.Where name (GreaterOrEqual value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a greater than or equal to (<tt>>=</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a greater than or equal to (<c>>=</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member GE<'T> name (value: 'T) = Field.GreaterOrEqual name value
|
|
|
|
static member GE<'T> name (value: 'T) = Field.GreaterOrEqual name value
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a less than (<tt><</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a less than (<c><</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member Less<'T> name (value: 'T) =
|
|
|
|
static member Less<'T> name (value: 'T) =
|
|
|
|
Field.Where name (Less value)
|
|
|
|
Field.Where name (Less value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a less than (<tt><</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a less than (<c><</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member LT<'T> name (value: 'T) = Field.Less name value
|
|
|
|
static member LT<'T> name (value: 'T) = Field.Less name value
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a less than or equal to (<tt><=</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a less than or equal to (<c><=</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member LessOrEqual<'T> name (value: 'T) =
|
|
|
|
static member LessOrEqual<'T> name (value: 'T) =
|
|
|
|
Field.Where name (LessOrEqual value)
|
|
|
|
Field.Where name (LessOrEqual value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a less than or equal to (<tt><=</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a less than or equal to (<c><=</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member LE<'T> name (value: 'T) = Field.LessOrEqual name value
|
|
|
|
static member LE<'T> name (value: 'T) = Field.LessOrEqual name value
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a not equals (<tt><></tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a not equals (<c><></c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member NotEqual<'T> name (value: 'T) =
|
|
|
|
static member NotEqual<'T> name (value: 'T) =
|
|
|
|
Field.Where name (NotEqual value)
|
|
|
|
Field.Where name (NotEqual value)
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a not equals (<tt><></tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a not equals (<c><></c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <param name="value">The value for the comparison</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
@@ -212,33 +212,33 @@ type Field = {
|
|
|
|
static member InArray<'T> name tableName (values: 'T seq) =
|
|
|
|
static member InArray<'T> name tableName (values: 'T seq) =
|
|
|
|
Field.Where name (InArray(tableName, Seq.map box values))
|
|
|
|
Field.Where name (InArray(tableName, Seq.map box values))
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create an exists (<tt>IS NOT NULL</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create an exists (<c>IS NOT NULL</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member Exists name =
|
|
|
|
static member Exists name =
|
|
|
|
Field.Where name Exists
|
|
|
|
Field.Where name Exists
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create an exists (<tt>IS NOT NULL</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create an exists (<c>IS NOT NULL</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member EX name = Field.Exists name
|
|
|
|
static member EX name = Field.Exists name
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a not exists (<tt>IS NULL</tt>) field criterion</summary>
|
|
|
|
/// <summary>Create a not exists (<c>IS NULL</c>) field criterion</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member NotExists name =
|
|
|
|
static member NotExists name =
|
|
|
|
Field.Where name NotExists
|
|
|
|
Field.Where name NotExists
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a not exists (<tt>IS NULL</tt>) field criterion (alias)</summary>
|
|
|
|
/// <summary>Create a not exists (<c>IS NULL</c>) field criterion (alias)</summary>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <param name="name">The name of the field to be compared</param>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
/// <returns>A field with the given comparison</returns>
|
|
|
|
static member NEX name = Field.NotExists name
|
|
|
|
static member NEX name = Field.NotExists name
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Transform a field name (<tt>a.b.c</tt>) to a path for the given SQL dialect</summary>
|
|
|
|
/// <summary>Transform a field name (<c>a.b.c</c>) to a path for the given SQL dialect</summary>
|
|
|
|
/// <param name="name">The name of the field in dotted format</param>
|
|
|
|
/// <param name="name">The name of the field in dotted format</param>
|
|
|
|
/// <param name="dialect">The SQL dialect to use when converting the name to nested path format</param>
|
|
|
|
/// <param name="dialect">The SQL dialect to use when converting the name to nested path format</param>
|
|
|
|
/// <param name="format">Whether to reference this path as a JSON value or a SQL value</param>
|
|
|
|
/// <param name="format">Whether to reference this path as a JSON value or a SQL value</param>
|
|
|
|
/// <returns>A <tt>string</tt> with the path required to address the nested document value</returns>
|
|
|
|
/// <returns>A <c>string</c> with the path required to address the nested document value</returns>
|
|
|
|
static member NameToPath (name: string) dialect format =
|
|
|
|
static member NameToPath (name: string) dialect format =
|
|
|
|
let path =
|
|
|
|
let path =
|
|
|
|
if name.Contains '.' then
|
|
|
|
if name.Contains '.' then
|
|
|
|
@@ -257,12 +257,12 @@ type Field = {
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create a field with a given name, but no other properties filled</summary>
|
|
|
|
/// <summary>Create a field with a given name, but no other properties filled</summary>
|
|
|
|
/// <param name="name">The field name, along with any other qualifications if used in a sorting context</param>
|
|
|
|
/// <param name="name">The field name, along with any other qualifications if used in a sorting context</param>
|
|
|
|
/// <remarks><tt>Comparison</tt> will be <tt>Equal</tt>, value will be an empty string</remarks>
|
|
|
|
/// <remarks><c>Comparison</c> will be <c>Equal</c>, value will be an empty string</remarks>
|
|
|
|
static member Named name =
|
|
|
|
static member Named name =
|
|
|
|
Field.Where name (Equal "")
|
|
|
|
Field.Where name (Equal "")
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Specify the name of the parameter for this field</summary>
|
|
|
|
/// <summary>Specify the name of the parameter for this field</summary>
|
|
|
|
/// <param name="name">The parameter name (including <tt>:</tt> or <tt>@</tt>)</param>
|
|
|
|
/// <param name="name">The parameter name (including <c>:</c> or <c>@</c>)</param>
|
|
|
|
/// <returns>A field with the given parameter name specified</returns>
|
|
|
|
/// <returns>A field with the given parameter name specified</returns>
|
|
|
|
member this.WithParameterName name =
|
|
|
|
member this.WithParameterName name =
|
|
|
|
{ this with ParameterName = Some name }
|
|
|
|
{ this with ParameterName = Some name }
|
|
|
|
@@ -276,7 +276,7 @@ type Field = {
|
|
|
|
/// <summary>Get the qualified path to the field</summary>
|
|
|
|
/// <summary>Get the qualified path to the field</summary>
|
|
|
|
/// <param name="dialect">The SQL dialect to use when converting the name to nested path format</param>
|
|
|
|
/// <param name="dialect">The SQL dialect to use when converting the name to nested path format</param>
|
|
|
|
/// <param name="format">Whether to reference this path as a JSON value or a SQL value</param>
|
|
|
|
/// <param name="format">Whether to reference this path as a JSON value or a SQL value</param>
|
|
|
|
/// <returns>A <tt>string</tt> with the qualified path required to address the nested document value</returns>
|
|
|
|
/// <returns>A <c>string</c> with the qualified path required to address the nested document value</returns>
|
|
|
|
member this.Path dialect format =
|
|
|
|
member this.Path dialect format =
|
|
|
|
(this.Qualifier |> Option.map (fun q -> $"{q}.") |> Option.defaultValue "")
|
|
|
|
(this.Qualifier |> Option.map (fun q -> $"{q}.") |> Option.defaultValue "")
|
|
|
|
+ Field.NameToPath this.Name dialect format
|
|
|
|
+ Field.NameToPath this.Name dialect format
|
|
|
|
@@ -286,10 +286,10 @@ type Field = {
|
|
|
|
[<Struct>]
|
|
|
|
[<Struct>]
|
|
|
|
type FieldMatch =
|
|
|
|
type FieldMatch =
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Any field matches (<tt>OR</tt>)</summary>
|
|
|
|
/// <summary>Any field matches (<c>OR</c>)</summary>
|
|
|
|
| Any
|
|
|
|
| Any
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>All fields match (<tt>AND</tt>)</summary>
|
|
|
|
/// <summary>All fields match (<c>AND</c>)</summary>
|
|
|
|
| All
|
|
|
|
| All
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>The SQL value implementing each matching strategy</summary>
|
|
|
|
/// <summary>The SQL value implementing each matching strategy</summary>
|
|
|
|
@@ -326,14 +326,14 @@ type AutoId =
|
|
|
|
/// <summary>Generate a MAX-plus-1 numeric value for documents</summary>
|
|
|
|
/// <summary>Generate a MAX-plus-1 numeric value for documents</summary>
|
|
|
|
| Number
|
|
|
|
| Number
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Generate a <tt>GUID</tt> for each document (as a lowercase, no-dashes, 32-character string)</summary>
|
|
|
|
/// <summary>Generate a <c>GUID</c> for each document (as a lowercase, no-dashes, 32-character string)</summary>
|
|
|
|
| Guid
|
|
|
|
| Guid
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Generate a random string of hexadecimal characters for each document</summary>
|
|
|
|
/// <summary>Generate a random string of hexadecimal characters for each document</summary>
|
|
|
|
| RandomString
|
|
|
|
| RandomString
|
|
|
|
with
|
|
|
|
with
|
|
|
|
/// <summary>Generate a <tt>GUID</tt> string</summary>
|
|
|
|
/// <summary>Generate a <c>GUID</c> string</summary>
|
|
|
|
/// <returns>A <tt>GUID</tt> string</returns>
|
|
|
|
/// <returns>A <c>GUID</c> string</returns>
|
|
|
|
static member GenerateGuid() =
|
|
|
|
static member GenerateGuid() =
|
|
|
|
System.Guid.NewGuid().ToString "N"
|
|
|
|
System.Guid.NewGuid().ToString "N"
|
|
|
|
|
|
|
|
|
|
|
|
@@ -487,10 +487,10 @@ module Configuration =
|
|
|
|
[<RequireQualifiedAccess>]
|
|
|
|
[<RequireQualifiedAccess>]
|
|
|
|
module Query =
|
|
|
|
module Query =
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Combine a query (<tt>SELECT</tt>, <tt>UPDATE</tt>, etc.) and a <tt>WHERE</tt> clause</summary>
|
|
|
|
/// <summary>Combine a query (<c>SELECT</c>, <c>UPDATE</c>, etc.) and a <c>WHERE</c> clause</summary>
|
|
|
|
/// <param name="statement">The first part of the statement</param>
|
|
|
|
/// <param name="statement">The first part of the statement</param>
|
|
|
|
/// <param name="where">The <tt>WHERE</tt> clause for the statement</param>
|
|
|
|
/// <param name="where">The <c>WHERE</c> clause for the statement</param>
|
|
|
|
/// <returns>The two parts of the query combined with <tt>WHERE</tt></returns>
|
|
|
|
/// <returns>The two parts of the query combined with <c>WHERE</c></returns>
|
|
|
|
[<CompiledName "StatementWhere">]
|
|
|
|
[<CompiledName "StatementWhere">]
|
|
|
|
let statementWhere statement where =
|
|
|
|
let statementWhere statement where =
|
|
|
|
$"%s{statement} WHERE %s{where}"
|
|
|
|
$"%s{statement} WHERE %s{where}"
|
|
|
|
@@ -500,7 +500,7 @@ module Query =
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>SQL statement to create a document table</summary>
|
|
|
|
/// <summary>SQL statement to create a document table</summary>
|
|
|
|
/// <param name="name">The name of the table to create (may include schema)</param>
|
|
|
|
/// <param name="name">The name of the table to create (may include schema)</param>
|
|
|
|
/// <param name="dataType">The type of data for the column (<tt>JSON</tt>, <tt>JSONB</tt>, etc.)</param>
|
|
|
|
/// <param name="dataType">The type of data for the column (<c>JSON</c>, <c>JSONB</c>, etc.)</param>
|
|
|
|
/// <returns>A query to create a document table</returns>
|
|
|
|
/// <returns>A query to create a document table</returns>
|
|
|
|
[<CompiledName "EnsureTableFor">]
|
|
|
|
[<CompiledName "EnsureTableFor">]
|
|
|
|
let ensureTableFor name dataType =
|
|
|
|
let ensureTableFor name dataType =
|
|
|
|
@@ -559,14 +559,14 @@ module Query =
|
|
|
|
/// <summary>Query to count documents in a table</summary>
|
|
|
|
/// <summary>Query to count documents in a table</summary>
|
|
|
|
/// <param name="tableName">The table in which to count documents (may include schema)</param>
|
|
|
|
/// <param name="tableName">The table in which to count documents (may include schema)</param>
|
|
|
|
/// <returns>A query to count documents</returns>
|
|
|
|
/// <returns>A query to count documents</returns>
|
|
|
|
/// <remarks>This query has no <tt>WHERE</tt> clause</remarks>
|
|
|
|
/// <remarks>This query has no <c>WHERE</c> clause</remarks>
|
|
|
|
[<CompiledName "Count">]
|
|
|
|
[<CompiledName "Count">]
|
|
|
|
let count tableName =
|
|
|
|
let count tableName =
|
|
|
|
$"SELECT COUNT(*) AS it FROM %s{tableName}"
|
|
|
|
$"SELECT COUNT(*) AS it FROM %s{tableName}"
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Query to check for document existence in a table</summary>
|
|
|
|
/// <summary>Query to check for document existence in a table</summary>
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
/// <param name="tableName">The table in which existence should be checked (may include schema)</param>
|
|
|
|
/// <param name="where">The <tt>WHERE</tt> clause with the existence criteria</param>
|
|
|
|
/// <param name="where">The <c>WHERE</c> clause with the existence criteria</param>
|
|
|
|
/// <returns>A query to check document existence</returns>
|
|
|
|
/// <returns>A query to check document existence</returns>
|
|
|
|
[<CompiledName "Exists">]
|
|
|
|
[<CompiledName "Exists">]
|
|
|
|
let exists tableName where =
|
|
|
|
let exists tableName where =
|
|
|
|
@@ -575,7 +575,7 @@ module Query =
|
|
|
|
/// <summary>Query to select documents from a table</summary>
|
|
|
|
/// <summary>Query to select documents from a table</summary>
|
|
|
|
/// <param name="tableName">The table from which documents should be found (may include schema)</param>
|
|
|
|
/// <param name="tableName">The table from which documents should be found (may include schema)</param>
|
|
|
|
/// <returns>A query to retrieve documents</returns>
|
|
|
|
/// <returns>A query to retrieve documents</returns>
|
|
|
|
/// <remarks>This query has no <tt>WHERE</tt> clause</remarks>
|
|
|
|
/// <remarks>This query has no <c>WHERE</c> clause</remarks>
|
|
|
|
[<CompiledName "Find">]
|
|
|
|
[<CompiledName "Find">]
|
|
|
|
let find tableName =
|
|
|
|
let find tableName =
|
|
|
|
$"SELECT data FROM %s{tableName}"
|
|
|
|
$"SELECT data FROM %s{tableName}"
|
|
|
|
@@ -583,7 +583,7 @@ module Query =
|
|
|
|
/// <summary>Query to update (replace) a document</summary>
|
|
|
|
/// <summary>Query to update (replace) a document</summary>
|
|
|
|
/// <param name="tableName">The table in which documents should be replaced (may include schema)</param>
|
|
|
|
/// <param name="tableName">The table in which documents should be replaced (may include schema)</param>
|
|
|
|
/// <returns>A query to update documents</returns>
|
|
|
|
/// <returns>A query to update documents</returns>
|
|
|
|
/// <remarks>This query has no <tt>WHERE</tt> clause</remarks>
|
|
|
|
/// <remarks>This query has no <c>WHERE</c> clause</remarks>
|
|
|
|
[<CompiledName "Update">]
|
|
|
|
[<CompiledName "Update">]
|
|
|
|
let update tableName =
|
|
|
|
let update tableName =
|
|
|
|
$"UPDATE %s{tableName} SET data = @data"
|
|
|
|
$"UPDATE %s{tableName} SET data = @data"
|
|
|
|
@@ -591,7 +591,7 @@ module Query =
|
|
|
|
/// <summary>Query to delete documents from a table</summary>
|
|
|
|
/// <summary>Query to delete documents from a table</summary>
|
|
|
|
/// <param name="tableName">The table in which documents should be deleted (may include schema)</param>
|
|
|
|
/// <param name="tableName">The table in which documents should be deleted (may include schema)</param>
|
|
|
|
/// <returns>A query to delete documents</returns>
|
|
|
|
/// <returns>A query to delete documents</returns>
|
|
|
|
/// <remarks>This query has no <tt>WHERE</tt> clause</remarks>
|
|
|
|
/// <remarks>This query has no <c>WHERE</c> clause</remarks>
|
|
|
|
[<CompiledName "Delete">]
|
|
|
|
[<CompiledName "Delete">]
|
|
|
|
let delete tableName =
|
|
|
|
let delete tableName =
|
|
|
|
$"DELETE FROM %s{tableName}"
|
|
|
|
$"DELETE FROM %s{tableName}"
|
|
|
|
@@ -604,10 +604,10 @@ module Query =
|
|
|
|
let selectFromTable tableName =
|
|
|
|
let selectFromTable tableName =
|
|
|
|
find tableName
|
|
|
|
find tableName
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>Create an <tt>ORDER BY</tt> clause for the given fields</summary>
|
|
|
|
/// <summary>Create an <c>ORDER BY</c> clause for the given fields</summary>
|
|
|
|
/// <param name="fields">One or more fields by which to order</param>
|
|
|
|
/// <param name="fields">One or more fields by which to order</param>
|
|
|
|
/// <param name="dialect">The SQL dialect for the generated clause</param>
|
|
|
|
/// <param name="dialect">The SQL dialect for the generated clause</param>
|
|
|
|
/// <returns>An <tt>ORDER BY</tt> clause for the given fields</returns>
|
|
|
|
/// <returns>An <c>ORDER BY</c> clause for the given fields</returns>
|
|
|
|
[<CompiledName "OrderBy">]
|
|
|
|
[<CompiledName "OrderBy">]
|
|
|
|
let orderBy fields dialect =
|
|
|
|
let orderBy fields dialect =
|
|
|
|
if Seq.isEmpty fields then ""
|
|
|
|
if Seq.isEmpty fields then ""
|
|
|
|
|