diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ff05e1c3..eebd7914 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -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 } diff --git a/Cargo.toml b/Cargo.toml index 1dd5e74b..16858b92 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pg_graphql" -version = "1.2.0" +version = "1.2.1" edition = "2021" [lib] @@ -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" @@ -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" diff --git a/dockerfiles/db/Dockerfile b/dockerfiles/db/Dockerfile index 7ae99f8d..dd66508e 100644 --- a/dockerfiles/db/Dockerfile +++ b/dockerfiles/db/Dockerfile @@ -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) diff --git a/docs/api.md b/docs/api.md index 94c6a70e..921d57e6 100644 --- a/docs/api.md +++ b/docs/api.md @@ -510,7 +510,6 @@ The following list shows the operators that may be available on `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 | diff --git a/docs/changelog.md b/docs/changelog.md index 0e8f908b..e6d0232c 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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 diff --git a/src/graphql.rs b/src/graphql.rs index 8533a158..8143e4cd 100644 --- a/src/graphql.rs +++ b/src/graphql.rs @@ -2989,7 +2989,6 @@ pub enum FilterOp { GreaterThan, GreaterThanEqualTo, In, - NotIn, Is, StartsWith, Like, @@ -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", @@ -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), @@ -3082,7 +3079,6 @@ impl ___Type for FilterTypeType { FilterOp::Equal, FilterOp::NotEqual, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ] } @@ -3095,7 +3091,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::Float => vec![ @@ -3106,7 +3101,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::String(_) => vec![ @@ -3117,7 +3111,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, FilterOp::StartsWith, FilterOp::Like, @@ -3133,7 +3126,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::Date => vec![ @@ -3144,7 +3136,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::Time => vec![ @@ -3155,7 +3146,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::Datetime => vec![ @@ -3166,7 +3156,6 @@ impl ___Type for FilterTypeType { FilterOp::GreaterThan, FilterOp::GreaterThanEqualTo, FilterOp::In, - FilterOp::NotIn, FilterOp::Is, ], Scalar::BigFloat => vec![ @@ -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], @@ -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 { diff --git a/src/transpile.rs b/src/transpile.rs index 9615976b..0bcc25b7 100644 --- a/src/transpile.rs +++ b/src/transpile.rs @@ -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(), }; @@ -671,7 +671,6 @@ impl FilterBuilderElem { FilterOp::GreaterThan => ">", FilterOp::GreaterThanEqualTo => ">=", FilterOp::In => "= any", - FilterOp::NotIn => "<> all", FilterOp::StartsWith => "^@", FilterOp::Like => "like", FilterOp::ILike => "ilike", diff --git a/test/expected/resolve_connection_filter.out b/test/expected/resolve_connection_filter.out index 96379784..8a7bdc6d 100644 --- a/test/expected/resolve_connection_filter.out +++ b/test/expected/resolve_connection_filter.out @@ -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 } } }}$$); @@ -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 } } }}$$); @@ -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 } } }}$$); @@ -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 } } }}$$); @@ -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 } } }}$$); @@ -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 } } }}$$, '{}'); diff --git a/test/expected/resolve_graphiql_schema.out b/test/expected/resolve_graphiql_schema.out index 6c419607..d30ffef1 100644 --- a/test/expected/resolve_graphiql_schema.out +++ b/test/expected/resolve_graphiql_schema.out @@ -993,24 +993,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "BigFloat", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -1124,24 +1106,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "BigInt", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -3031,24 +2995,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "Date", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -3162,24 +3108,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "Datetime", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -3317,24 +3245,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "Float", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -3483,24 +3393,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "Int", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -5473,24 +5365,6 @@ begin; "description": null, + "defaultValue": null + }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "String", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + - }, + { + "name": "regex", + "type": { + @@ -5623,24 +5497,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "Time", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + @@ -5714,24 +5570,6 @@ begin; }, + "description": null, + "defaultValue": null + - }, + - { + - "name": "nin", + - "type": { + - "kind": "LIST", + - "name": null, + - "ofType": { + - "kind": "NON_NULL", + - "name": null, + - "ofType": { + - "kind": "SCALAR", + - "name": "UUID", + - "ofType": null + - } + - } + - }, + - "description": null, + - "defaultValue": null + } + ], + "possibleTypes": null + diff --git a/test/sql/resolve_connection_filter.sql b/test/sql/resolve_connection_filter.sql index fa327e7d..f2dcc85f 100644 --- a/test/sql/resolve_connection_filter.sql +++ b/test/sql/resolve_connection_filter.sql @@ -133,50 +133,26 @@ begin; select graphql.resolve($${accountCollection(filter: {id: {in: [1, 2]}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - int - select graphql.resolve($${accountCollection(filter: {id: {nin: [1, 2]}}) { edges { node { id } } }}$$); - rollback to savepoint a; - -- in - int coerce to list select graphql.resolve($${accountCollection(filter: {id: {in: 2}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - int coerce to list - select graphql.resolve($${accountCollection(filter: {id: {nin: 2}}) { edges { node { id } } }}$$); - rollback to savepoint a; - -- in - text select graphql.resolve($${accountCollection(filter: {name: {in: ["foo", "bar"]}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - text - select graphql.resolve($${accountCollection(filter: {name: {nin: ["foo", "bar"]}}) { edges { node { id } } }}$$); - rollback to savepoint a; - -- in - text coerce to list select graphql.resolve($${accountCollection(filter: {name: {in: "baz"}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - text coerce to list - select graphql.resolve($${accountCollection(filter: {name: {nin: "baz"}}) { edges { node { id } } }}$$); - rollback to savepoint a; - -- in - empty list select graphql.resolve($${accountCollection(filter: {name: {in: []}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - empty list - select graphql.resolve($${accountCollection(filter: {name: {nin: []}}) { edges { node { id } } }}$$); - rollback to savepoint a; - -- in - null literal returns nothing select graphql.resolve($${accountCollection(filter: {name: {in: null}}) { edges { node { id } } }}$$); rollback to savepoint a; - -- nin - null literal returns nothing - select graphql.resolve($${accountCollection(filter: {name: {nin: null}}) { edges { node { id } } }}$$); - 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 } } }}$$, '{}'); rollback to savepoint a;