Skip to content
Snippets Groups Projects
Unverified Commit 3ab5ecd0 authored by Cam Saul's avatar Cam Saul
Browse files

fixup! Add new JSON options column to Database [ci skip]

parent 56de9c3e
Branches
Tags
No related merge requests found
......@@ -289,7 +289,7 @@ const OPERATORS_BY_TYPE_ORDERED = {
{ name: "DOES_NOT_CONTAIN", verboseName: t`Does not contain`},
{ name: "IS_NULL", verboseName: t`Is empty`, advanced: true },
{ name: "NOT_NULL", verboseName: t`Not empty`, advanced: true },
{ name: "STARTS_WITH", verboseName: t`Starts with`, advanced: true},
{00 name: "STARTS_WITH", verboseName: t`Starts with`, advanced: true},
{ name: "ENDS_WITH", verboseName: t`Ends with`, advanced: true}
],
[STRING_LIKE]: [
......
......@@ -121,7 +121,12 @@ export type NotFilter = ["not", Filter];
export type EqualityFilter = ["="|"!=", ConcreteField, Value];
export type ComparisonFilter = ["<"|"<="|">="|">", ConcreteField, OrderableValue];
export type BetweenFilter = ["between", ConcreteField, OrderableValue, OrderableValue];
export type StringFilter = ["starts-with"|"contains"|"does-not-contain"|"ends-with", ConcreteField, StringLiteral];
export type StringFilter = ["starts-with"|"contains"|"does-not-contain"|"ends-with", ConcreteField, StringLiteral] |
["starts-with"|"contains"|"does-not-contain"|"ends-with", ConcreteField, StringLiteral, StringFilterOptions];
export type StringFilterOptions = {
"case-sensitive?"?: false
};
export type NullFilter = ["is-null", ConcreteField];
export type NotNullFilter = ["not-null", ConcreteField];
......@@ -129,6 +134,7 @@ export type InsideFilter = ["inside", ConcreteField, ConcreteField, Numeri
export type TimeIntervalFilter = ["time-interval", ConcreteField, RelativeDatetimePeriod, RelativeDatetimeUnit] |
["time-interval", ConcreteField, RelativeDatetimePeriod, RelativeDatetimeUnit, FilterOptions];
// TODO - rename this to TimeIntervalFilterOptions because it is only used for those types of filters
export type FilterOptions = {
"include-current"?: bool
}
......
......@@ -296,26 +296,27 @@
added. For backwards-compatibility, and to avoid possible performance implications, case-sensitive is the default
option if no `options-maps` is specified."
([filter-type f s]
(string-filter filter-type f s {:case-sensitive? true}))
(string-filter filter-type f s {:case-sensitive true}))
([filter-type f s options-map]
(i/strict-map->StringFilter (assoc options-map
:filter-type filter-type
:field (field f)
:value (value f s)))))
(i/strict-map->StringFilter
{:filter-type filter-type
:field (field f)
:value (value f s)
:case-sensitive? (qputil/get-normalized options-map :case-sensitive true)})))
(def ^:ql ^{:arglists '([f s] [f s options-map])} starts-with
"Filter subclause. Return results where F starts with the string S. By default, is case-sensitive, but you may pass an
`options-map` with `{:case-sensitive? false}` for case-insensitive searches."
`options-map` with `{:case-sensitive false}` for case-insensitive searches."
(partial string-filter :starts-with))
(def ^:ql ^{:arglists '([f s] [f s options-map])} contains
"Filter subclause. Return results where F contains the string S. By default, is case-sensitive, but you may pass an
`options-map` with `{:case-sensitive? false}` for case-insensitive searches."
`options-map` with `{:case-sensitive false}` for case-insensitive searches."
(partial string-filter :contains))
(def ^:ql ^{:arglists '([f s] [f s options-map])} ends-with
"Filter subclause. Return results where F ends with with the string S. By default, is case-sensitive, but you may pass
an `options-map` with `{:case-sensitive? false}` for case-insensitive searches."
an `options-map` with `{:case-sensitive false}` for case-insensitive searches."
(partial string-filter :ends-with))
......
......@@ -164,7 +164,7 @@
[[41 "Cheese Steak Shop" 18 37.7855 -122.44 1]
[74 "Chez Jay" 2 34.0104 -118.493 2]]
(-> (data/run-query venues
(ql/filter (ql/starts-with $name "CHE" {:case-sensitive? false}))
(ql/filter (ql/starts-with $name "CHE" {:case-sensitive false}))
(ql/order-by (ql/asc $id)))
rows formatted-venues-rows))
......@@ -195,7 +195,7 @@
[45 "Tu Lan Restaurant" 4 37.7821 -122.41 1]
[55 "Dal Rae Restaurant" 67 33.983 -118.096 4]]
(-> (data/run-query venues
(ql/filter (ql/ends-with $name "RESTAURANT" {:case-sensitive? false}))
(ql/filter (ql/ends-with $name "RESTAURANT" {:case-sensitive false}))
(ql/order-by (ql/asc $id)))
rows formatted-venues-rows))
......@@ -223,7 +223,7 @@
[34 "Beachwood BBQ & Brewing" 10 33.7701 -118.191 2]
[39 "Baby Blues BBQ" 5 34.0003 -118.465 2]]
(-> (data/run-query venues
(ql/filter (ql/contains $name "bbq" {:case-sensitive? false}))
(ql/filter (ql/contains $name "bbq" {:case-sensitive false}))
(ql/order-by (ql/asc $id)))
rows formatted-venues-rows))
......
......@@ -409,7 +409,7 @@
:rows [["Mediterannian"] ["Mexican"]]}
(data (data/run-query checkins
(ql/breakout $venue_category_name)
(ql/filter (ql/starts-with $venue_category_name "ME" {:case-sensitive? false})))))
(ql/filter (ql/starts-with $venue_category_name "ME" {:case-sensitive false})))))
;;; filter ENDS_WITH
(expect-with-timeseries-dbs
......@@ -445,7 +445,7 @@
["Mexican"]]}
(data (data/run-query checkins
(ql/breakout $venue_category_name)
(ql/filter (ql/ends-with $venue_category_name "AN" {:case-sensitive? false})))))
(ql/filter (ql/ends-with $venue_category_name "AN" {:case-sensitive false})))))
;;; filter CONTAINS
(expect-with-timeseries-dbs
......@@ -481,7 +481,7 @@
["Southern"]]}
(data (data/run-query checkins
(ql/breakout $venue_category_name)
(ql/filter (ql/contains $venue_category_name "eR" {:case-sensitive? false})))))
(ql/filter (ql/contains $venue_category_name "eR" {:case-sensitive false})))))
;;; order by aggregate field (?)
(expect-with-timeseries-dbs
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment