Giter Site home page Giter Site logo

Comments (9)

abbychau avatar abbychau commented on August 18, 2024 1

done

from diesel_cli_ext.

Boscop avatar Boscop commented on August 18, 2024

Ah, I just saw that you only generate it when Identifiable is derived.
I think the inverse logic would be better:
When a table has primary key(s), append Identifiable to the list of derives!
Because the custom derives can only be specified to be the same for ALL tables, but not all tables might have primary keys..

from diesel_cli_ext.

abbychau avatar abbychau commented on August 18, 2024

I am quite confused with this requirement.
On tables with primary keys are Identifiable .

and

The primary_key attribute is only applicable when deriving Identifiable.

from diesel_cli_ext.

Boscop avatar Boscop commented on August 18, 2024

Yes, I mean, it would make sense to automatically add Identifiable to the list of derives when a table has a primary key! And then also automatically generate #[primary_key(..)].

Because the list of derives can only be specified to be the same for all tables but not all tables might have primary keys.

from diesel_cli_ext.

abbychau avatar abbychau commented on August 18, 2024

Do you meant to add a flag so to automatically take the first field as the primary if no primary_key is provided?

from diesel_cli_ext.

Boscop avatar Boscop commented on August 18, 2024

@abbychau No, I meant the primary key should be inferred from the table!{}. But I also mean that if a table has a primary key, Identifiable should be auto-added to the list of derives such that #[primary_key(..)] will be generated as well. (Not requiring the programmer to specify Identifiable in the list of custom derives, because it might not apply to all tables, since not all tables might have primary keys.)

from diesel_cli_ext.

abbychau avatar abbychau commented on August 18, 2024

@abbychau No, I meant the primary key should be inferred from the table!{}. But I also mean that if a table has a primary key, Identifiable should be auto-added to the list of derives such that #[primary_key(..)] will be generated as well. (Not requiring the programmer to specify Identifiable in the list of custom derives, because it might not apply to all tables, since not all tables might have primary keys.)

How do you want it to be inferred? It can be in any name and may not be listed as the first field as well.

from diesel_cli_ext.

Boscop avatar Boscop commented on August 18, 2024

@abbychau The same way it's inferred right now, when Identifiable is specified: The columns that constitute the primary key are listed in parens after the name of the table.

from diesel_cli_ext.

abbychau avatar abbychau commented on August 18, 2024

oh, I missed the parens (eyes covered by ghosts) :p
It is workable. Thanks for the explanation.

from diesel_cli_ext.

Related Issues (20)

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.