diff --git a/sea-query-derive/src/enum_def.rs b/sea-query-derive/src/enum_def.rs index dfe1829ae..14ea5689f 100644 --- a/sea-query-derive/src/enum_def.rs +++ b/sea-query-derive/src/enum_def.rs @@ -89,12 +89,6 @@ pub fn expand(args: TokenStream, input: TokenStream) -> TokenStream { } } - impl #import_name::Iden for #enum_name { - fn unquoted(&self) -> &str { - ::as_str(&self) - } - } - impl ::std::convert::AsRef for #enum_name { fn as_ref(&self) -> &str { ::as_str(&self) diff --git a/sea-query-derive/src/iden/iden_static.rs b/sea-query-derive/src/iden/iden_static.rs index 119eadcd7..64a5fac67 100644 --- a/sea-query-derive/src/iden/iden_static.rs +++ b/sea-query-derive/src/iden/iden_static.rs @@ -20,11 +20,7 @@ pub fn expand(input: DeriveInput) -> TokenStream { fields: Fields::Unit, .. }) => { - let impl_iden = impl_iden_for_unit_struct(&ident, &table_name); - return quote! { - #impl_iden - impl #sea_query_path::IdenStatic for #ident { fn as_str(&self) -> &'static str { #table_name @@ -49,8 +45,6 @@ pub fn expand(input: DeriveInput) -> TokenStream { return TokenStream::new(); } - let impl_iden = impl_iden_for_enum(&ident, &table_name, variants.iter()); - let match_arms = match variants .iter() .map(|v| (table_name.as_str(), v)) @@ -62,8 +56,6 @@ pub fn expand(input: DeriveInput) -> TokenStream { }; let output = quote! { - #impl_iden - impl #sea_query_path::IdenStatic for #ident { fn as_str(&self) -> &'static str { match self { diff --git a/sea-query-derive/src/iden/mod.rs b/sea-query-derive/src/iden/mod.rs index f48ac199c..cefd4e043 100644 --- a/sea-query-derive/src/iden/mod.rs +++ b/sea-query-derive/src/iden/mod.rs @@ -47,7 +47,19 @@ pub fn expand(input: DeriveInput) -> TokenStream { return TokenStream::new(); } - let output = impl_iden_for_enum(&ident, &table_name, variants.iter()); + let can_be_static = variants.iter().all(|v| { + let variant = IdenVariant::::try_from((table_name.as_str(), v)); + match variant { + Ok(v) => v.can_be_static(), + Err(_) => false, + } + }); + + let output = if can_be_static { + impl_iden_static_for_enum(&ident, &table_name, variants.iter()) + } else { + impl_iden_for_enum(&ident, &table_name, variants.iter()) + }; output.into() } @@ -57,25 +69,10 @@ fn impl_iden_for_unit_struct( table_name: &str, ) -> proc_macro2::TokenStream { let sea_query_path = sea_query_path(); - - if is_static_iden(table_name) { - quote! { - impl #sea_query_path::Iden for #ident { - fn quoted(&self) -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed(#table_name) - } - - fn unquoted(&self) -> &str { - #table_name - } - } - } - } else { - quote! { - impl #sea_query_path::Iden for #ident { - fn unquoted(&self) -> &str { - #table_name - } + quote! { + impl #sea_query_path::IdenStatic for #ident { + fn as_str(&self) -> &'static str { + #table_name } } } @@ -91,43 +88,48 @@ where { let sea_query_path = sea_query_path(); - let mut is_all_static_iden = true; - let match_arms = match variants - .map(|v| { - let v = IdenVariant::::try_from((table_name, v))?; - is_all_static_iden &= v.is_static_iden(); - Ok(v) - }) + .map(|v| IdenVariant::::try_from((table_name, v))) .collect::>>() { Ok(v) => v, Err(e) => return e.to_compile_error(), }; - if is_all_static_iden { - quote! { - impl #sea_query_path::Iden for #ident { - fn quoted(&self) -> std::borrow::Cow<'static, str> { - std::borrow::Cow::Borrowed(match self { - #(#match_arms),* - }) - } - - fn unquoted(&self) -> &str { - match self { - #(#match_arms),* - } + quote! { + impl #sea_query_path::Iden for #ident { + fn unquoted(&self) -> std::borrow::Cow<'static, str> { + match self { + #(#match_arms),* } } } - } else { - quote! { - impl #sea_query_path::Iden for #ident { - fn unquoted(&self) -> &str { - match self { - #(#match_arms),* - } + } +} + +fn impl_iden_static_for_enum<'a, T>( + ident: &proc_macro2::Ident, + table_name: &str, + variants: T, +) -> proc_macro2::TokenStream +where + T: Iterator, +{ + let sea_query_path = sea_query_path(); + + let match_arms = match variants + .map(|v| IdenVariant::::try_from((table_name, v))) + .collect::>>() + { + Ok(v) => v, + Err(e) => return e.to_compile_error(), + }; + + quote! { + impl #sea_query_path::IdenStatic for #ident { + fn as_str(&self) -> &'static str { + match self { + #(#match_arms),* } } } @@ -190,11 +192,3 @@ fn find_attr(attrs: &[Attribute]) -> Option<&Attribute> { attr.path().is_ident(&IdenPath::Iden) || attr.path().is_ident(&IdenPath::Method) }) } - -pub fn is_static_iden(name: &str) -> bool { - // can only begin with [a-z_] - name.chars() - .take(1) - .all(|c| c == '_' || c.is_ascii_alphabetic()) - && name.chars().all(|c| c == '_' || c.is_ascii_alphanumeric()) -} diff --git a/sea-query-derive/src/iden/write_arm.rs b/sea-query-derive/src/iden/write_arm.rs index 3d120d6b7..879a9ab30 100644 --- a/sea-query-derive/src/iden/write_arm.rs +++ b/sea-query-derive/src/iden/write_arm.rs @@ -6,18 +6,26 @@ use proc_macro2::{Span, TokenStream}; use quote::{ToTokens, TokenStreamExt, quote}; use syn::{Error, Fields, FieldsNamed, Ident, Variant}; -use super::{ - DeriveIden, DeriveIdenStatic, attr::IdenAttr, error::ErrorMsg, find_attr, is_static_iden, -}; +use super::{DeriveIden, DeriveIdenStatic, attr::IdenAttr, error::ErrorMsg, find_attr}; pub(crate) trait WriteArm { fn variant(variant: TokenStream, name: TokenStream) -> TokenStream; + fn renamed_variant(variant: TokenStream, name: &str) -> TokenStream; + fn method_variant(variant: TokenStream, method: &syn::Ident) -> TokenStream; fn flattened(variant: TokenStream, name: &Ident) -> TokenStream; } impl WriteArm for DeriveIden { fn variant(variant: TokenStream, name: TokenStream) -> TokenStream { - quote! { Self::#variant => #name } + quote! { Self::#variant => std::borrow::Cow::Borrowed(#name) } + } + + fn renamed_variant(variant: TokenStream, name: &str) -> TokenStream { + quote! { Self::#variant => std::borrow::Cow::Owned(#name.to_owned()) } + } + + fn method_variant(variant: TokenStream, method: &syn::Ident) -> TokenStream { + quote! { Self::#variant => std::borrow::Cow::Owned(self.#method().to_owned()) } } fn flattened(variant: TokenStream, name: &Ident) -> TokenStream { @@ -30,6 +38,14 @@ impl WriteArm for DeriveIdenStatic { quote! { Self::#variant => #name } } + fn renamed_variant(variant: TokenStream, name: &str) -> TokenStream { + quote! { Self::#variant => #name } + } + + fn method_variant(variant: TokenStream, method: &syn::Ident) -> TokenStream { + quote! { Self::#variant => self.#method() } + } + fn flattened(variant: TokenStream, name: &Ident) -> TokenStream { quote! { Self::#variant => #name.as_str() } } @@ -165,33 +181,31 @@ where } fn write_variant_name(&self, variant: TokenStream) -> TokenStream { - let name = self - .attr - .as_ref() - .map(|a| match a { - IdenAttr::Rename(name) => quote! { #name }, - IdenAttr::Method(method) => quote! { self.#method() }, - IdenAttr::Flatten => unreachable!(), - }) - .unwrap_or_else(|| { + match &self.attr { + Some(IdenAttr::Rename(name)) => T::renamed_variant(variant, name), + Some(IdenAttr::Method(method)) => T::method_variant(variant, method), + Some(IdenAttr::Flatten) => unreachable!(), + None => { let name = self.table_or_snake_case(); - quote! { #name } - }); - - T::variant(variant, name) + T::variant(variant, quote! { #name }) + } + } } - pub(crate) fn is_static_iden(&self) -> bool { - let name: String = match &self.attr { - Some(a) => match a { - IdenAttr::Rename(name) => name.to_owned(), - IdenAttr::Method(_) => return false, - IdenAttr::Flatten => return false, - }, - None => self.table_or_snake_case(), - }; - - is_static_iden(&name) + pub(crate) fn can_be_static(&self) -> bool { + match (&self.fields, &self.attr) { + // Unit variants are always static + (Fields::Unit, None) => true, + (Fields::Unit, Some(IdenAttr::Rename(_))) => true, + // Method variants cannot be static (return &str, not &'static str) + (_, Some(IdenAttr::Method(_))) => false, + // Flattened variants could be static if the inner type is IdenStatic, + // but we can't easily determine that at compile time, so assume they cannot be + (_, Some(IdenAttr::Flatten)) => false, + // Non-unit variants cannot be static + (Fields::Named(_), _) => false, + (Fields::Unnamed(_), _) => false, + } } } diff --git a/sea-query-derive/tests/pass/flattened_named.rs b/sea-query-derive/tests/pass/flattened_named.rs index 0a39575e2..2f91abf9f 100644 --- a/sea-query-derive/tests/pass/flattened_named.rs +++ b/sea-query-derive/tests/pass/flattened_named.rs @@ -1,6 +1,6 @@ use sea_query::Iden; -use strum::{EnumIter, IntoEnumIterator}; use std::borrow::Cow; +use strum::{EnumIter, IntoEnumIterator}; #[derive(Copy, Clone, Iden, EnumIter)] enum Asset { @@ -36,6 +36,6 @@ fn main() { .zip(expected) .for_each(|(var, exp)| { assert_eq!(var.to_string(), exp); - assert_eq!(var.quoted(), Cow::Borrowed(exp)); + assert_eq!(var.unquoted(), Cow::Borrowed(exp)); }) } diff --git a/sea-query-derive/tests/pass/meta_list_renaming_everything.rs b/sea-query-derive/tests/pass/meta_list_renaming_everything.rs index 06ffa4e76..70ec3d9f1 100644 --- a/sea-query-derive/tests/pass/meta_list_renaming_everything.rs +++ b/sea-query-derive/tests/pass/meta_list_renaming_everything.rs @@ -1,6 +1,6 @@ use sea_query::{Iden, IntoIden, MysqlQueryBuilder, PostgresQueryBuilder, QuotedBuilder}; -use strum::{EnumIter, IntoEnumIterator}; use std::borrow::Cow; +use strum::{EnumIter, IntoEnumIterator}; #[derive(Iden, EnumIter)] // Outer iden attributes overrides what's used for "Table"... @@ -38,7 +38,7 @@ fn main() { .map(|var| var.to_string()) .zip(expected) .for_each(|(iden, exp)| assert_eq!(iden, exp)); - + let mut string = String::new(); PostgresQueryBuilder.prepare_iden(&Custom::Email("".to_owned()).into_iden(), &mut string); assert_eq!(string, "\"EM`ail\""); @@ -47,5 +47,5 @@ fn main() { MysqlQueryBuilder.prepare_iden(&Custom::Email("".to_owned()).into_iden(), &mut string); assert_eq!(string, "`EM``ail`"); - assert!(matches!(Custom::FirstName.quoted(), Cow::Owned(_))); + assert!(matches!(Custom::FirstName.unquoted(), Cow::Owned(_))); } diff --git a/src/backend/mod.rs b/src/backend/mod.rs index 21d91030b..f5ce8b7bc 100644 --- a/src/backend/mod.rs +++ b/src/backend/mod.rs @@ -1,7 +1,6 @@ //! Translating the SQL AST into engine-specific SQL statements. use crate::*; -use std::borrow::Cow; #[cfg(feature = "backend-mysql")] #[cfg_attr(docsrs, doc(cfg(feature = "backend-mysql")))] @@ -46,17 +45,12 @@ pub trait QuotedBuilder { let qq = q.1 as char; sql.write_char(q.left()).unwrap(); - match &iden.0 { - Cow::Borrowed(s) => sql.write_str(s).unwrap(), - Cow::Owned(s) => { - for char in s.chars() { - if char == qq { - sql.write_char(char).unwrap() - } - sql.write_char(char).unwrap() - } + for char in iden.0.chars() { + if char == qq { + sql.write_char(char).unwrap() } - }; + sql.write_char(char).unwrap() + } sql.write_char(q.right()).unwrap(); } } diff --git a/src/extension/mysql/column.rs b/src/extension/mysql/column.rs index 0bcd52905..48f3c20a0 100644 --- a/src/extension/mysql/column.rs +++ b/src/extension/mysql/column.rs @@ -1,4 +1,4 @@ -use crate::Iden; +use crate::IdenStatic; #[derive(Debug, Copy, Clone)] #[non_exhaustive] @@ -8,8 +8,8 @@ pub enum MySqlType { LongBlob, } -impl Iden for MySqlType { - fn unquoted(&self) -> &str { +impl IdenStatic for MySqlType { + fn as_str(&self) -> &'static str { match self { Self::TinyBlob => "tinyblob", Self::MediumBlob => "mediumblob", diff --git a/src/extension/postgres/ltree.rs b/src/extension/postgres/ltree.rs index 917d45a0d..4a08c671c 100644 --- a/src/extension/postgres/ltree.rs +++ b/src/extension/postgres/ltree.rs @@ -1,4 +1,4 @@ -use crate::Iden; +use crate::{Iden, IdenStatic}; /// PostgreSQL `ltree` extension type. /// @@ -50,8 +50,8 @@ use crate::Iden; #[derive(Debug, Clone, Eq, PartialEq)] pub struct PgLTree; -impl Iden for PgLTree { - fn unquoted(&self) -> &str { +impl IdenStatic for PgLTree { + fn as_str(&self) -> &'static str { "ltree" } } diff --git a/src/extension/postgres/types.rs b/src/extension/postgres/types.rs index 40b18a102..5a6ce079b 100644 --- a/src/extension/postgres/types.rs +++ b/src/extension/postgres/types.rs @@ -154,8 +154,8 @@ impl TypeDropStatement { /// /// struct FontFamily; /// - /// impl Iden for FontFamily { - /// fn unquoted(&self) -> &str { + /// impl IdenStatic for FontFamily { + /// fn as_str(&self) -> &'static str { /// "font_family" /// } /// } @@ -254,8 +254,8 @@ impl TypeAlterStatement { /// Monospace, /// } /// - /// impl Iden for FontFamily { - /// fn unquoted(&self) -> &str { + /// impl IdenStatic for FontFamily { + /// fn as_str(&self) -> &'static str { /// match self { /// Self::Type => "font_family", /// Self::Serif => "serif", diff --git a/src/lib.rs b/src/lib.rs index 8867dab02..1b5cd2bb3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -664,8 +664,8 @@ //! # use sea_query::{*, tests_cfg::*}; //! struct MyFunction; //! -//! impl Iden for MyFunction { -//! fn unquoted(&self) -> &str { +//! impl IdenStatic for MyFunction { +//! fn as_str(&self) -> &'static str { //! "MY_FUNCTION" //! } //! } diff --git a/src/tests_cfg.rs b/src/tests_cfg.rs index 256249cf8..4db5e43e8 100644 --- a/src/tests_cfg.rs +++ b/src/tests_cfg.rs @@ -3,7 +3,7 @@ #[cfg(feature = "with-json")] pub use serde_json::json; -use crate::Iden; +use crate::IdenStatic; /// Representation of a database table named `Character`. /// @@ -27,8 +27,8 @@ pub enum Character { /// A shorthand for [`Character`] pub type Char = Character; -impl Iden for Character { - fn unquoted(&self) -> &str { +impl IdenStatic for Character { + fn as_str(&self) -> &'static str { match self { Self::Table => "character", Self::Id => "id", @@ -58,8 +58,8 @@ pub enum Font { Language, } -impl Iden for Font { - fn unquoted(&self) -> &str { +impl IdenStatic for Font { + fn as_str(&self) -> &'static str { match self { Self::Table => "font", Self::Id => "id", @@ -84,8 +84,8 @@ pub enum Glyph { Tokens, } -impl Iden for Glyph { - fn unquoted(&self) -> &str { +impl IdenStatic for Glyph { + fn as_str(&self) -> &'static str { match self { Self::Table => "glyph", Self::Id => "id", @@ -108,8 +108,8 @@ pub enum Task { IsDone, } -impl Iden for Task { - fn unquoted(&self) -> &str { +impl IdenStatic for Task { + fn as_str(&self) -> &'static str { match self { Self::Table => "task", Self::Id => "id", diff --git a/src/types/iden/core.rs b/src/types/iden/core.rs index 38c7aeac5..56cd5abb4 100644 --- a/src/types/iden/core.rs +++ b/src/types/iden/core.rs @@ -1,82 +1,69 @@ //! "Core", low-level identifier types. use std::{borrow::Cow, fmt::Debug}; -/// Identifier +/// A Rust type that represents an SQL identifier. +/// +/// This could be something like a cheap enum that's rendered into an SQL string later. +/// In those cases, prefer implementing [`IdenStatic`] instead if implementing [`Iden`] directly. pub trait Iden { - /// Return the to-be sanitized version of the identifier. - /// - /// For example, for MySQL "hel`lo`" would have to be escaped as "hel``lo". - /// Note that this method doesn't do the actual escape, - /// as it's backend specific. - /// It only indicates whether the identifier needs to be escaped. - /// - /// If the identifier doesn't need to be escaped, return `'static str`. - /// This can be deduced at compile-time by the `Iden` macro, - /// or using the [`is_static_iden`] function. - /// - /// `Cow::Owned` would always be escaped. - fn quoted(&self) -> Cow<'static, str> { - Cow::Owned(self.to_string()) - } - /// A shortcut for writing an [`unquoted`][Iden::unquoted] - /// identifier into a [`String`]. + /// identifier into an owned [`String`]. /// /// We can't reuse [`ToString`] for this, because [`ToString`] uses /// the [`Display`][std::fmt::Display] representation. But [`Iden`] /// representation is distinct from [`Display`][std::fmt::Display] /// and can be different. fn to_string(&self) -> String { - self.unquoted().to_owned() + self.unquoted().into() } - /// Write a raw identifier string without quotes. + /// Return a raw identifier string without quotes. /// /// We intentionally don't reuse [`Display`][std::fmt::Display] for /// this, because we want to allow it to have a different logic. - fn unquoted(&self) -> &str; -} - -impl Iden for &'static str { - fn quoted(&self) -> Cow<'static, str> { - if is_static_iden(self) { - Cow::Borrowed(self) - } else { - Cow::Owned(String::from(*self)) - } - } - - fn unquoted(&self) -> &str { - self - } + fn unquoted(&self) -> Cow<'static, str>; } impl Iden for String { - fn quoted(&self) -> Cow<'static, str> { + fn unquoted(&self) -> Cow<'static, str> { Cow::Owned(self.clone()) } +} - fn unquoted(&self) -> &str { - self +impl Iden for T +where + T: IdenStatic, +{ + fn unquoted(&self) -> Cow<'static, str> { + Cow::Borrowed(self.as_str()) } } -#[cfg(feature = "thread-safe")] -/// Identifier statically known at compile-time. -pub trait IdenStatic: Iden + Copy + Send + Sync + 'static { +/// An SQL identifier ([`Iden`]) that's statically known at compile-time. +/// +/// When possible, prefer implementing [`IdenStatic`] instead of implementing [`Iden`] directly. +pub trait IdenStatic { + /// Return a raw identifier string without quotes, just like [`Iden::unquoted`]. + /// + /// With an additional guarantee that it's a statically known string that doesn't need to be allocated at runtime. fn as_str(&self) -> &'static str; } -#[cfg(not(feature = "thread-safe"))] -/// Identifier statically known at compile-time. -pub trait IdenStatic: Iden + Copy + 'static { - fn as_str(&self) -> &'static str; +impl IdenStatic for &'static str { + fn as_str(&self) -> &'static str { + self + } } -/// A prepared (quoted) identifier string. +/// A string that represents an SQL identifier (like a column name). +/// +/// At this stage, it's a raw unprepared string without quotes. +/// The SQL codegen backend will quote it later, in a DB-specific manner. +/// +/// ## Why it's called `DynIden` /// /// The naming is legacy and kept for compatibility. -/// This used to be an alias for a `dyn Iden` object that's lazily rendered later. +/// `DynIden` used to be an alias for a `dyn Iden` object that's lazily rendered later. /// /// Nowadays, it's an eagerly-rendered string. /// Most identifiers are static strings that aren't "rendered" at runtime anyway. @@ -113,13 +100,13 @@ where T: Iden, { fn from(iden: T) -> Self { - DynIden(iden.quoted()) + DynIden(iden.unquoted()) } } /// An explicit wrapper for [`Iden`]s which are dynamic user-provided strings. /// -/// Nowadays, `&str` implements [`Iden`] and can be used directly. +/// Nowadays, `String`/`&str` implement [`Iden`] and can be used directly. #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)] pub struct Alias(pub String); @@ -133,13 +120,9 @@ impl Alias { } impl Iden for Alias { - fn quoted(&self) -> Cow<'static, str> { + fn unquoted(&self) -> Cow<'static, str> { Cow::Owned(self.0.clone()) } - - fn unquoted(&self) -> &str { - &self.0 - } } /// Null Alias @@ -152,8 +135,8 @@ impl NullAlias { } } -impl Iden for NullAlias { - fn unquoted(&self) -> &str { +impl IdenStatic for NullAlias { + fn as_str(&self) -> &'static str { "" } } @@ -213,44 +196,3 @@ impl Iden for NullAlias { /// ``` #[derive(Default, Debug, Clone, Copy)] pub struct Asterisk; - -/// Return whether this identifier needs to be escaped. -/// Right now we're very safe and only return true for identifiers -/// composed of `a-zA-Z0-9_`. -/// -/// ``` -/// use sea_query::is_static_iden; -/// -/// assert!(is_static_iden("abc")); -/// assert!(is_static_iden("a_b_c")); -/// assert!(!is_static_iden("a-b-c")); -/// assert!(is_static_iden("abc123")); -/// assert!(!is_static_iden("123abc")); -/// assert!(!is_static_iden("a|b|c")); -/// assert!(!is_static_iden("a'b'c")); -/// ``` -pub const fn is_static_iden(string: &str) -> bool { - let bytes = string.as_bytes(); - if bytes.is_empty() { - return true; - } - - // can only begin with [a-z_] - if bytes[0] == b'_' || (bytes[0] as char).is_ascii_alphabetic() { - // good - } else { - return false; - } - - let mut i = 1; - while i < bytes.len() { - if bytes[i] == b'_' || (bytes[i] as char).is_ascii_alphanumeric() { - // good - } else { - return false; - } - i += 1; - } - - true -} diff --git a/src/types/mod.rs b/src/types/mod.rs index 3c02d6a1a..0163cf60a 100644 --- a/src/types/mod.rs +++ b/src/types/mod.rs @@ -39,17 +39,17 @@ pub struct SeaRc; impl SeaRc { /// A legacy method, kept for compatibility. /// - /// Nowadays, instead of wrapping an `Iden` object, + /// Nowadays, instead of wrapping an [`Iden`] object, /// it eagerly "renders" it into a string and then drops the object. /// - /// Note that most `Iden`s are statically known + /// Note that most [`Iden`]s are [statically known][IdenStatic], /// and their representations aren't actually "rendered" and allocated at runtime. #[allow(clippy::new_ret_no_self)] pub fn new(i: I) -> DynIden where I: Iden, { - DynIden(i.quoted()) + DynIden(i.unquoted()) } pub fn clone(iden: &DynIden) -> DynIden { diff --git a/tests/common.rs b/tests/common.rs index d64e4dd20..6a7a3bf72 100644 --- a/tests/common.rs +++ b/tests/common.rs @@ -1,4 +1,4 @@ -use sea_query::Iden; +use sea_query::IdenStatic; /// Representation of a database table named `BloB`. /// @@ -18,8 +18,8 @@ pub enum BinaryType { LongBlob, } -impl Iden for BinaryType { - fn unquoted(&self) -> &str { +impl IdenStatic for BinaryType { + fn as_str(&self) -> &'static str { match self { Self::Table => "binary_type", Self::BinaryLen => "binlen", diff --git a/tests/postgres/types.rs b/tests/postgres/types.rs index 80631faab..f53f7f985 100644 --- a/tests/postgres/types.rs +++ b/tests/postgres/types.rs @@ -40,8 +40,8 @@ fn create_3() { BreakfastTea, } - impl sea_query::Iden for Tea { - fn unquoted(&self) -> &str { + impl sea_query::IdenStatic for Tea { + fn as_str(&self) -> &'static str { match self { Self::Enum => "tea", Self::EverydayTea => "EverydayTea",