Skip to content

Commit

Permalink
Merge pull request #366 from supabase/or/remove-not-in-pending-not
Browse files Browse the repository at this point in the history
Removes nin filter pending addition of generic NOT, bump to 1.2.1
  • Loading branch information
olirice authored Jun 14, 2023
2 parents 06f9136 + beb2379 commit 08293bc
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 256 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
package_name:
- pg-graphql
pgrx_version:
- 0.8.3
- 0.9.5
postgres: [14, 15]
box:
- { runner: ubuntu-20.04, arch: amd64 }
Expand Down
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pg_graphql"
version = "1.2.0"
version = "1.2.1"
edition = "2021"

[lib]
Expand All @@ -13,7 +13,7 @@ pg15 = ["pgrx/pg15", "pgrx-tests/pg15"]
pg_test = []

[dependencies]
pgrx = "=0.8.3"
pgrx = "=0.9.5"
graphql-parser = "0.4"
serde = { version = "1.0", features = ["rc"] }
serde_json = "1.0"
Expand All @@ -26,7 +26,7 @@ base64 = "0.13"
lazy_static = "1"

[dev-dependencies]
pgrx-tests = "=0.8.3"
pgrx-tests = "=0.9.5"

[profile.dev]
panic = "unwind"
Expand Down
2 changes: 1 addition & 1 deletion dockerfiles/db/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ RUN \
cargo --version

# PGX
RUN cargo install cargo-pgrx --version 0.8.3 --locked
RUN cargo install cargo-pgrx --version 0.9.5 --locked

RUN cargo pgrx init --pg15 $(which pg_config)

Expand Down
1 change: 0 additions & 1 deletion docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ The following list shows the operators that may be available on `<Type>Filter` t
| gt | Greater Than |
| gte | Greater Than Or Equal To |
| in | Contained by Value List |
| nin | Not Contained by Value List |
| lt | Less Than |
| lte | Less Than Or Equal To |
| is | Null or Not Null |
Expand Down
5 changes: 4 additions & 1 deletion docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
- bugfix: PostgreSQL type modifiers, e.g. char(n), no longer truncate excess text
- bugfix: Creating a new enum variant between existing variants no longer errors

## master
## 1.2.1
- feature: `String` type filters support `regex`, `iregex`
- feature: computed relationships via functions returning setof
- bugfix: function based computed columns with same name no longer error

## master
14 changes: 1 addition & 13 deletions src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2989,7 +2989,6 @@ pub enum FilterOp {
GreaterThan,
GreaterThanEqualTo,
In,
NotIn,
Is,
StartsWith,
Like,
Expand All @@ -3008,7 +3007,6 @@ impl ToString for FilterOp {
Self::GreaterThan => "gt",
Self::GreaterThanEqualTo => "gte",
Self::In => "in",
Self::NotIn => "nin",
Self::Is => "is",
Self::StartsWith => "startsWith",
Self::Like => "like",
Expand All @@ -3032,7 +3030,6 @@ impl FromStr for FilterOp {
"gt" => Ok(Self::GreaterThan),
"gte" => Ok(Self::GreaterThanEqualTo),
"in" => Ok(Self::In),
"nin" => Ok(Self::NotIn),
"is" => Ok(Self::Is),
"startsWith" => Ok(Self::StartsWith),
"like" => Ok(Self::Like),
Expand Down Expand Up @@ -3082,7 +3079,6 @@ impl ___Type for FilterTypeType {
FilterOp::Equal,
FilterOp::NotEqual,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
]
}
Expand All @@ -3095,7 +3091,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::Float => vec![
Expand All @@ -3106,7 +3101,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::String(_) => vec![
Expand All @@ -3117,7 +3111,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
FilterOp::StartsWith,
FilterOp::Like,
Expand All @@ -3133,7 +3126,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::Date => vec![
Expand All @@ -3144,7 +3136,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::Time => vec![
Expand All @@ -3155,7 +3146,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::Datetime => vec![
Expand All @@ -3166,7 +3156,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::BigFloat => vec![
Expand All @@ -3177,7 +3166,6 @@ impl ___Type for FilterTypeType {
FilterOp::GreaterThan,
FilterOp::GreaterThanEqualTo,
FilterOp::In,
FilterOp::NotIn,
FilterOp::Is,
],
Scalar::Opaque => vec![FilterOp::Equal, FilterOp::Is],
Expand Down Expand Up @@ -3205,7 +3193,7 @@ impl ___Type for FilterTypeType {
default_value: None,
sql_type: None,
},
FilterOp::In | FilterOp::NotIn => __InputValue {
FilterOp::In => __InputValue {
name_: op.to_string(),
type_: __Type::List(ListType {
type_: Box::new(__Type::NonNull(NonNullType {
Expand Down
3 changes: 1 addition & 2 deletions src/transpile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ impl FilterBuilderElem {
}
_ => {
let cast_type_name = match op {
FilterOp::In | FilterOp::NotIn => format!("{}[]", column.type_name),
FilterOp::In => format!("{}[]", column.type_name),
_ => column.type_name.clone(),
};

Expand All @@ -671,7 +671,6 @@ impl FilterBuilderElem {
FilterOp::GreaterThan => ">",
FilterOp::GreaterThanEqualTo => ">=",
FilterOp::In => "= any",
FilterOp::NotIn => "<> all",
FilterOp::StartsWith => "^@",
FilterOp::Like => "like",
FilterOp::ILike => "ilike",
Expand Down
48 changes: 0 additions & 48 deletions test/expected/resolve_connection_filter.out
Original file line number Diff line number Diff line change
Expand Up @@ -254,14 +254,6 @@ begin;
{"data": {"accountCollection": {"edges": [{"node": {"id": 1}}, {"node": {"id": 2}}]}}}
(1 row)

rollback to savepoint a;
-- nin - int
select graphql.resolve($${accountCollection(filter: {id: {nin: [1, 2]}}) { edges { node { id } } }}$$);
resolve
-------------------------------------------------------------------
{"data": {"accountCollection": {"edges": [{"node": {"id": 3}}]}}}
(1 row)

rollback to savepoint a;
-- in - int coerce to list
select graphql.resolve($${accountCollection(filter: {id: {in: 2}}) { edges { node { id } } }}$$);
Expand All @@ -270,14 +262,6 @@ begin;
{"data": {"accountCollection": {"edges": [{"node": {"id": 2}}]}}}
(1 row)

rollback to savepoint a;
-- nin - int coerce to list
select graphql.resolve($${accountCollection(filter: {id: {nin: 2}}) { edges { node { id } } }}$$);
resolve
----------------------------------------------------------------------------------------
{"data": {"accountCollection": {"edges": [{"node": {"id": 1}}, {"node": {"id": 3}}]}}}
(1 row)

rollback to savepoint a;
-- in - text
select graphql.resolve($${accountCollection(filter: {name: {in: ["foo", "bar"]}}) { edges { node { id } } }}$$);
Expand All @@ -286,14 +270,6 @@ begin;
{"data": {"accountCollection": {"edges": [{"node": {"id": 1}}, {"node": {"id": 2}}]}}}
(1 row)

rollback to savepoint a;
-- nin - text
select graphql.resolve($${accountCollection(filter: {name: {nin: ["foo", "bar"]}}) { edges { node { id } } }}$$);
resolve
-------------------------------------------------------------------
{"data": {"accountCollection": {"edges": [{"node": {"id": 3}}]}}}
(1 row)

rollback to savepoint a;
-- in - text coerce to list
select graphql.resolve($${accountCollection(filter: {name: {in: "baz"}}) { edges { node { id } } }}$$);
Expand All @@ -302,14 +278,6 @@ begin;
{"data": {"accountCollection": {"edges": [{"node": {"id": 3}}]}}}
(1 row)

rollback to savepoint a;
-- nin - text coerce to list
select graphql.resolve($${accountCollection(filter: {name: {nin: "baz"}}) { edges { node { id } } }}$$);
resolve
----------------------------------------------------------------------------------------
{"data": {"accountCollection": {"edges": [{"node": {"id": 1}}, {"node": {"id": 2}}]}}}
(1 row)

rollback to savepoint a;
-- in - empty list
select graphql.resolve($${accountCollection(filter: {name: {in: []}}) { edges { node { id } } }}$$);
Expand All @@ -318,14 +286,6 @@ begin;
{"data": {"accountCollection": {"edges": []}}}
(1 row)

rollback to savepoint a;
-- nin - empty list
select graphql.resolve($${accountCollection(filter: {name: {nin: []}}) { edges { node { id } } }}$$);
resolve
-------------------------------------------------------------------------------------------------------------
{"data": {"accountCollection": {"edges": [{"node": {"id": 1}}, {"node": {"id": 2}}, {"node": {"id": 3}}]}}}
(1 row)

rollback to savepoint a;
-- in - null literal returns nothing
select graphql.resolve($${accountCollection(filter: {name: {in: null}}) { edges { node { id } } }}$$);
Expand All @@ -334,14 +294,6 @@ begin;
{"data": {"accountCollection": {"edges": []}}}
(1 row)

rollback to savepoint a;
-- nin - null literal returns nothing
select graphql.resolve($${accountCollection(filter: {name: {nin: null}}) { edges { node { id } } }}$$);
resolve
------------------------------------------------
{"data": {"accountCollection": {"edges": []}}}
(1 row)

rollback to savepoint a;
-- variable in - absent treated as ignored / returns all
select graphql.resolve($$query AAA($nin: [String!]) { accountCollection(filter: {name: {in: $nin}}) { edges { node { id } } }}$$, '{}');
Expand Down
Loading

0 comments on commit 08293bc

Please sign in to comment.