Skip to content

Commit

Permalink
Phoenix update support for "IN" operator
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinRay97 committed Dec 3, 2024
1 parent 65bb657 commit 255e9f0
Show file tree
Hide file tree
Showing 5 changed files with 244 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object NoRelationshipsQueryGenerator : BaseQueryGenerator() {
ApplyBinaryComparisonOperator.IN -> col.`in`(value)
ApplyBinaryComparisonOperator.IS_NULL -> col.isNull
ApplyBinaryComparisonOperator.LIKE -> col.like(value as Field<String>)
ApplyBinaryComparisonOperator.CONTAINS -> col.contains(value as Field<String>)
}
}

Expand All @@ -50,7 +51,7 @@ object NoRelationshipsQueryGenerator : BaseQueryGenerator() {
DSL.table(DSL.unquotedName(request.collection))
).apply {
if (request.query.predicate != null) {
where(expressionToCondition(request.query.predicate!!, request))
where(expressionToConditionPhoenixNoTableNameInPredicates(request.query.predicate!!, request))
}
if (request.query.order_by != null) {
orderBy(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ class PhoenixDataConnectorService @Inject constructor(
override val jooqDialect = SQLDialect.DEFAULT
override val jooqSettings =
commonDSLContextSettings
.withRenderQuotedNames(RenderQuotedNames.EXPLICIT_DEFAULT_QUOTED)
.withRenderQuotedNames(RenderQuotedNames.EXPLICIT_DEFAULT_UNQUOTED)
.withRenderOptionalAsKeywordForFieldAliases(RenderOptionalKeyword.ON)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ object PhoenixJDBCSchemaGenerator : JDBCSchemaGenerator() {
"_eq" to ComparisonOperatorDefinition.Equal,
"_contains" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.STRING.name)),
"_like" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.STRING.name)),
"_in" to ComparisonOperatorDefinition.In
),
aggregate_functions = mapOf(
"min" to AggregateFunctionDefinition(result_type = Type.Named(NDCScalar.STRING.name)),
Expand All @@ -78,7 +79,8 @@ object PhoenixJDBCSchemaGenerator : JDBCSchemaGenerator() {
"_lt" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATETIME.name)),
"_gte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATETIME.name)),
"_lte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATETIME.name)),
"_eq" to ComparisonOperatorDefinition.Equal
"_eq" to ComparisonOperatorDefinition.Equal,
"_in" to ComparisonOperatorDefinition.In
),
aggregate_functions = emptyMap()
),
Expand All @@ -88,7 +90,8 @@ object PhoenixJDBCSchemaGenerator : JDBCSchemaGenerator() {
"_lt" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATE.name)),
"_gte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATE.name)),
"_lte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.DATE.name)),
"_eq" to ComparisonOperatorDefinition.Equal
"_eq" to ComparisonOperatorDefinition.Equal,
"_in" to ComparisonOperatorDefinition.In
),
aggregate_functions = emptyMap()
),
Expand All @@ -98,7 +101,8 @@ object PhoenixJDBCSchemaGenerator : JDBCSchemaGenerator() {
"_lt" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.TIME.name)),
"_gte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.TIME.name)),
"_lte" to ComparisonOperatorDefinition.Custom(argument_type = Type.Named(NDCScalar.TIME.name)),
"_eq" to ComparisonOperatorDefinition.Equal
"_eq" to ComparisonOperatorDefinition.Equal,
"_in" to ComparisonOperatorDefinition.In
),
aggregate_functions = emptyMap()
),
Expand Down
2 changes: 2 additions & 0 deletions ndc-ir/src/main/kotlin/io/hasura/ndc/ir/Query.kt
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ enum class ApplyBinaryComparisonOperator {
IS_NULL,
@JsonProperty("_like")
LIKE,
@JsonProperty("_contains")
CONTAINS,
}

enum class ApplyUnaryComparisonOperator {
Expand Down
Loading

0 comments on commit 255e9f0

Please sign in to comment.