Skip to content

Commit

Permalink
Ensure a bunch of unsupported capabilities excluded during compile time
Browse files Browse the repository at this point in the history
  • Loading branch information
SevInf committed Dec 22, 2023
1 parent 5d218b4 commit afc35d7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions query-engine/schema/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ query-structure = { path = "../query-structure" }
psl.workspace = true
rustc-hash = "1.1.0"
once_cell = "1"
enumflags2 = "0.7"

[dev-dependencies]
codspeed-criterion-compat = "1.1.0"
Expand Down
19 changes: 18 additions & 1 deletion query-engine/schema/src/query_schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,23 @@ enum Operation {

type LazyField = Box<dyn for<'a> Fn(&'a QuerySchema) -> OutputField<'a> + Send + Sync>;

const CAPABILITIES: ConnectorCapabilities = enumflags2::make_bitflags!(ConnectorCapability::{
AnyId |
AutoIncrement |
CompoundIds |
SqlQueryRaw |
RelationFieldsInArbitraryOrder |
UpdateableId |
ImplicitManyToManyRelation |
DecimalType |
BackwardCompatibleQueryRaw |
OrderByNullsFirstLast |
SupportsTxIsolationSerializable |
NativeUpsert |
FilteredInlineChildNestedToOneDisconnect |
RowIn
});

/// The query schema defines which operations (query/mutations) are possible on a database, based
/// on a Prisma schema.
///
Expand Down Expand Up @@ -101,7 +118,7 @@ impl QuerySchema {
}

pub fn has_capability(&self, capability: ConnectorCapability) -> bool {
self.connector.has_capability(capability)
CAPABILITIES.contains(capability)
}

pub fn capabilities(&self) -> ConnectorCapabilities {
Expand Down

0 comments on commit afc35d7

Please sign in to comment.