Comments (9)
done
from diesel_cli_ext.
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.
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.
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.
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.
@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 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 specifyIdentifiable
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.
@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.
oh, I missed the parens (eyes covered by ghosts) :p
It is workable. Thanks for the explanation.
from diesel_cli_ext.
Related Issues (20)
- Suggestion: Allow using custom type for certain table columns
- Suggestion: Allow excluding certain tables from generation HOT 3
- Fails on schema inside `mod` HOT 6
- Suggestion: per-table derive modification
- Suggestion: Allow overriding models struct name for given table
- #[derive(Queryable, Debug{trace1})] HOT 5
- Several types generated by print-schema for MySQL not recognized HOT 6
- Suggestion: Add jsonb support HOT 3
- Update version on crates.io HOT 1
- diesel_ext -m failing to read src/schema.rs HOT 3
- deprecation warning for #[table_name] macro attribute HOT 10
- Type alias issue in Diesel 2.0
- Fails on schema containing `pub mod`
- add-table-name should output `table_name` as table instead of string
- thread 'main' panicked at 'index not found'
- Problem with generating model using schema in table names. HOT 1
- add_table_name with diesel v2 is missing diesel prelude
- Valid UTF-8 HOT 1
- Proposition to Community For Feature Implementation HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from diesel_cli_ext.