Comments (1)
We do face the same issues. Currently, our work around for this is to use #[serde(alias = 'some_unique_name')]
for each of the fields of the struct. So considering your use case, it will look something like:
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Default)]
pub struct User {
#[serde(alias='user_table_id')]
pub id: i32,
#[serde(alias='user_table_date')]
pub date: DateTime<Utc>,
#[serde(alias='user_table_group_id')]
pub group_id: i32,
}
#[derive(Debug, Clone, Eq, PartialEq, Hash, Serialize, Deserialize, Default)]
pub struct Group {
#[serde(alias='group_table_id')]
pub id: i32,
#[serde(alias='group_table_name')]
pub name: String,
}
And then modify your query to include those names, like so:
let rows = db_conn
.query(
"SELECT users.id as user_table_id,
users.date as user_table_date,
users.group_id as user_table_group_id,
groups.id as group_table_id,
groups.name as group_table_name
FROM users
JOIN groups ON users.group_id = groups.id
WHERE users.user_id = ?1 LIMIT ?2
",
params![user_id.clone(), 10],
)
.await?;
while let Some(row) = rows.next().await? {
let user = from_row<User>(&row)?;
let group = from_row<Group>(&row)?;
}
Although this seems like a lot of work, but since the query is mostly generated programmatically, this is a fair bit easier to work with. But I totally agree with you that if there was some solution to this directly from libsql, it would be a huge help.
from libsql.
Related Issues (20)
- libsql `de::from_row` does not support serde flatten
- Cloudflare Worker issue
- Cgo Driver like mattn/go-sqlite3? HOT 1
- Insert queries take an enormous amount of time with replicas HOT 1
- Support shared in memory DBs
- Expose libsql version in c binding
- Inconsistent/incorrect savepoint results in remote and remote_replica connections
- Turso -schema DBs don't work with Goose migrations HOT 6
- iOS/Android support HOT 6
- Unix sockets for embedded libsql
- SELECT Query still does a FULL TABLE SCAN. HOT 4
- Interactive Transaction on :memory: fails with missing table
- [C Bindings] missing column type enum HOT 2
- [C Bindings] Missing get declared type API on rows
- Expose `VACUUM` in libSQL server?
- [C Bindings] Missing reset prepared statement HOT 5
- [C Bindings] Missing load extension HOT 2
- [C Bindings] Missing hook function HOT 3
- Error: Access is denied.
- Async runtime assumption for libsql rust
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 libsql.