Giter Club home page Giter Club logo

Comments (5)

Fyko avatar Fyko commented on August 15, 2024

I don't think the code for this exists, but it could be implemented on StructField.
By adding column_name to StructField, I believe the name of the column on the struct could be changed.

struct Trans;

impl Transformer for Trans {
    fn struct_field(&self, _struct_table: StructTable, column_name: &str) -> StructField {
        StructField {
            json: None,
            is_nullable: true,
            attributes: Default::default(),
			column_name: if column_name == "type" {
				"r#type".to_string()
			} else { column_name }
        }
    }
}

let ident = format_ident!("{}", column.column_name);

Then, the above line can be rewritten to

 let ident = format_ident!("{}", struct_field.column_name); 

However, this doesn't consider the distinction between the column name in the database versus the struct.

It seems the only place the actual column name matters is in the const queries, which are passed down here, on line 124:

let entity_write = EntityWriter {
table,
struct_name: &struct_name,
struct_field_metadata,
transformer: &transformer,
columns: &columns,
};

from catalytic.

Jasperav avatar Jasperav commented on August 15, 2024

Hey @carterhimmel, thanks for reporting this issue. I understand the issue you are facing, and you are correct it should be customized through StructField. I can have a look next week since I am now on holiday :).

from catalytic.

Fyko avatar Fyko commented on August 15, 2024

Sounds good! I will say, I was able to get it done but a few more misc. problems arose.
master...trufflehq:catalytic:feat/column_name

from catalytic.

Jasperav avatar Jasperav commented on August 15, 2024

@carterhimmel I just published a new version of this library with custom field names (#36), let me know if there are any issues!

from catalytic.

Fyko avatar Fyko commented on August 15, 2024

Thank you! Will get around to testing it this week! :)

from catalytic.

Related Issues (14)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.