GithubHelp home page GithubHelp logo

typed-sql's People

Contributors

matthunz avatar robjtede avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

typed-sql's Issues

Support multiple fields using Queryable trait

Is not possible use multiple fields using Queryable trait in a struct.

#[derive(Table)]
struct Task {
    id: u64,
    description: String,
    is_done: bool,
}

#[derive(Queryable)]
struct TaskQuery {
    description: String,
    is_done: bool,
}

let mounted_query = Task::table().query(TaskQuery::queryable()).to_sql();

02

Instead of the wildcard (*) be: SELECT * FROM tasks;, is possible to define the fields in the final query?

Example: SELECT description, is_done FROM tasks;

Excellent approach of this lib, following the concept 'Security by design'.
Thanks.

Remove unnecessary feature gate, permitting compilation on stable

There's currently a feature gate on line 71 of src/lib.rs. After cloning this repository locally, I can confirm that removing this line has no effect whatsoever, indicating that it was unnecessary to begin with. By removing this, the crate will compile on stable.

Add `RETURNING` clause support.

To insert the increasing IDs can be useful to be able to get the result of the insertion.

This is a very crude example, but I would like to have an interface similar to:

#[derive(Default, Debug, typed_sql::Table)]
struct SomeStruct {
    // It can be represent like NULL if it None.
    // ..or it can just be ignored.
    id: Option<u64>,

    some_useful_data: u128,
}

let insert = SomeStruct::table()
    .insert(SomeStruct::default())
    .returns(|some_struct| some_struct.id)
    .to_sql();

assert_eq!(
    insert,
    "INSERT into somestruct(some_useful_data) VALUES (0) RETURNING id;"
);

Is it possible to manually rename the table?

Hey,

I love this project, and I am very excited to try it out, however I ran into a problem, where the name of my table is different from the struct name (as it is namespaced).

Are you able to change the table name in any way for a struct derived with Table?
My code looks like this:

#[derive(Table, FromRow, Debug)]
struct Parent {
    id: i32,
    first_name: String,
    last_name: String,
}

In Diesel I believe they allow you to add #[table_name="people_parent"] to change the name of a table. Do you have a similar feature planned/does it exist?

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.