Comments (5)
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 }
}
}
}
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:
Catalytic/catalytic_table_to_struct/src/lib.rs
Lines 119 to 125 in 026feab
from catalytic.
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.
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.
@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.
Thank you! Will get around to testing it this week! :)
from catalytic.
Related Issues (14)
- CI has Trybuild: Overwrite env variable HOT 1
- Fix SerializedValues::with_capacity HOT 3
- Re-export scylla driver HOT 1
- primary_key_owned should call primary_key().to_owned() HOT 1
- Upload to crates HOT 1
- `catalytic_table_to_struct` can't make some materialized views HOT 4
- Docs Improvements HOT 3
- User defined types (UDT) Types are supported? HOT 3
- Macro-based code generation instead of using `build.rs` HOT 1
- Can't compile Catalytic 0.1.20 version with scylla_macros 0.2.2 HOT 8
- RUSTSEC-2021-0141: dotenv is Unmaintained HOT 1
- Is the project gonna keep being maintained? HOT 1
- Implement TIMESTAMP/TIMEOUT for inserts
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 catalytic.