-
Notifications
You must be signed in to change notification settings - Fork 5
cast int64 and numeric to string by default #416
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 12 commits
efd5f64
f8dc828
3e628cf
d7097a1
ca7d2e3
bedf73d
8f90b96
0314d62
36ab489
55dc327
867a734
0df5ca1
3d56da8
9ef3d24
7fa9b4f
8a7a2d7
f1f15ce
f3ca583
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ pub struct State { | |
} | ||
|
||
#[derive(Debug)] | ||
/// Used for generating a unique name for intermediate tables. | ||
pub struct TableAliasIndex(pub u64); | ||
|
||
#[derive(Debug)] | ||
|
@@ -89,7 +90,7 @@ pub enum CollectionInfo<'env> { | |
} | ||
|
||
#[derive(Debug)] | ||
/// Metadata information about a specific collection. | ||
/// Metadata information about a specific collection or composite type. | ||
pub enum CompositeTypeInfo<'env> { | ||
CollectionInfo(CollectionInfo<'env>), | ||
CompositeTypeInfo { | ||
|
@@ -114,8 +115,7 @@ impl<'request> Env<'request> { | |
} | ||
} | ||
|
||
/// Lookup a collection's information in the metadata. | ||
|
||
/// Lookup collection or composite type. | ||
pub fn lookup_composite_type( | ||
&self, | ||
type_name: &'request str, | ||
|
@@ -138,6 +138,7 @@ impl<'request> Env<'request> { | |
} | ||
} | ||
|
||
/// Lookup a collection's information in the metadata. | ||
pub fn lookup_collection( | ||
&self, | ||
collection_name: &'request str, | ||
|
@@ -202,6 +203,18 @@ impl<'request> Env<'request> { | |
}) | ||
} | ||
|
||
/// Lookup type representation of a type. | ||
pub fn lookup_type_representation( | ||
&self, | ||
scalar_type: &metadata::ScalarType, | ||
) -> Option<metadata::TypeRepresentation> { | ||
self.metadata | ||
.type_representations | ||
.0 | ||
.get(scalar_type) | ||
.cloned() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stupid nitpick: we only use this as a reference so we could probably return one and not need to clone it. This is stupid because cloning it will be cheap. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. smart. thanks! |
||
} | ||
|
||
/// Try to get the variables table reference. This will fail if no variables were passed | ||
/// as part of the query request. | ||
pub fn get_variables_table(&self) -> Result<sql::ast::TableReference, Error> { | ||
|
@@ -262,6 +275,30 @@ impl CompositeTypeInfo<'_> { | |
)), | ||
} | ||
} | ||
|
||
/// Fetch all the field names (external, internal) of a composite type. | ||
pub fn fields(&self) -> Vec<(&String, &String)> { | ||
match self { | ||
CompositeTypeInfo::CompositeTypeInfo { name: _, info } => info | ||
.fields | ||
.iter() | ||
.map(|(name, field)| (name, &field.name)) | ||
.collect::<Vec<_>>(), | ||
|
||
CompositeTypeInfo::CollectionInfo(collection_info) => match collection_info { | ||
CollectionInfo::Table { name: _, info } => info | ||
.columns | ||
.iter() | ||
.map(|(name, column)| (name, &column.name)) | ||
.collect::<Vec<_>>(), | ||
CollectionInfo::NativeQuery { name: _, info } => info | ||
.columns | ||
.iter() | ||
.map(|(name, column)| (name, &column.name)) | ||
.collect::<Vec<_>>(), | ||
}, | ||
} | ||
} | ||
} | ||
|
||
impl Default for State { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the mapping between our internal type representations and ndc-spec type representations.