Repository: diesel-rs/diesel
File: diesel_cli/src/infer_schema_internals/data_structures.rs (Rust)

Code before:
    pub nullable: bool,
    pub max_length: Option<u64>,
    pub comment: Option<String>,
}

#[derive(Debug, PartialEq, Clone, Eq)]
pub struct ColumnType {
    pub schema: Option<String>,
    pub rust_name: String,
    pub sql_name: String,
    pub is_array: bool,
    pub is_nullable: bool,
    pub is_unsigned: bool,
    pub max_length: Option<u64>,
}

impl ColumnType {
    pub(crate) fn for_column_def(c: &ColumnDef) -> Result<Self, Box<dyn Error + Send + Sync>> {
        Ok(Self::for_type_path(
            &c.tpe,
            c.max_length
                .as_ref()
                .map(|l| {
                    l.base10_parse::<u64>()
                        .map_err(|e| -> Box<dyn Error + Send + Sync> {
                            format!("Column length litteral can't be parsed as u64: {e}").into()
                        })
                })
                .transpose()?,
        ))
    }

    fn for_type_path(t: &syn::TypePath, max_length: Option<u64>) -> Self {
        let last = t
            .path
            .segments
            .last()
            .expect("At least one segment in this type-path");

        let mut ret = Self {
            schema: None,
            rust_name: last.ident.to_string(),
            sql_name: String::new(),
            is_array: last.ident == "Array",
            is_nullable: last.ident == "Nullable",
            is_unsigned: last.ident == "Unsigned",
            max_length,
        };

        let sql_name = if !ret.is_nullable && !ret.is_array && !ret.is_unsigned {
            last.ident

Review comment (suggestion):
```suggestion
                            format!("Column length literal can't be parsed as u64: {e}").into()
```

Code after:
    pub rust_name: String,
    pub sql_name: String,
    pub is_array: bool,
    pub is_nullable: bool,
    pub is_unsigned: bool,
    pub max_length: Option<u64>,
}

impl ColumnType {
    pub(crate) fn for_column_def(c: &ColumnDef) -> Result<Self, Box<dyn Error + Send + Sync>> {
        Ok(Self::for_type_path(
            &c.tpe,
            c.max_length
                .as_ref()
                .map(|l| {
                    l.base10_parse::<u64>()
                        .map_err(|e| -> Box<dyn Error + Send + Sync> {
                            format!("Column length literal can't be parsed as u64: {e}").into()
                        })
                })
                .transpose()?,
        ))
    }

    fn for_type_path(t: &syn::TypePath, max_length: Option<u64>) -> Self {
        let last = t
            .path
            .segments
            .last()
            .expect("At least one segment in this type-path");

        let mut ret = Self {
            schema: None,
            rust_name: last.ident.to_string(),
            sql_name: String::new(),
            is_array: last.ident == "Array",
            is_nullable: last.ident == "Nullable",
            is_unsigned: last.ident == "Unsigned",
            max_length,
        };

        let sql_name = if !ret.is_nullable && !ret.is_array && !ret.is_unsigned {
            last.ident
                .to_string()
                .split('_')
                .collect::<Vec<_>>()
                .join(" ")
        } else if let syn::PathArguments::AngleBracketed(ref args) = last.arguments {
            let arg = args.args.first().expect("There is at least one argument");
            if let syn::GenericArgument::Type(syn::Type::Path(p)) = arg {
                let s = Self::for_type_path(p, max_length);