Giter VIP home page Giter VIP logo

Comments (4)

panarch avatar panarch commented on July 19, 2024 1

Sure, this worked fine for select(). for update() I tried the other day and was not working.

thanks, yes it was only working for select().
I've just added concat filter support to ast builder update nodes.
this will be included in the next release.

ref.
Update AST builder UpdateFilterNode .filter(..) behavior, #1455
Update AST builder UpdateNode to enforce .filter(..) before .set(..), #1454

from gluesql.

devgony avatar devgony commented on July 19, 2024

To use AND or OR expression, you should do like this.

        .filter(
            col("name")
                .not_like(text("D%"))
                .and(col("name").not_like(text("M___"))),
        )

https://github.com/gluesql/gluesql/blob/main/test-suite/src/ast_builder/expr/pattern_matching.rs#L69
or

        .filter("c.name = 'Fruit' OR c.name = 'Meat'")

https://github.com/gluesql/gluesql/blob/main/test-suite/src/ast_builder/select.rs#L85

from gluesql.

panarch avatar panarch commented on July 19, 2024

Originally I had a misunderstanding on AST builder syntax and I thought adding .filter() multiple times will keep adding nested filter, but turns out every new filter was just overriding another filter.

adding filter multiple times should work like below,
if it wasn't then could you provide the query you tested?

// filter node -> filter node -> build
let actual = table("Bar")
.select()
.filter("id IS NULL")
.filter("id > 10")
.filter("id < 20")
.build();
let expected = "SELECT * FROM Bar WHERE id IS NULL AND id > 10 AND id < 20";
test(actual, expected);

from gluesql.

kanekoshoyu avatar kanekoshoyu commented on July 19, 2024

To use AND or OR expression, you should do like this.

        .filter(
            col("name")
                .not_like(text("D%"))
                .and(col("name").not_like(text("M___"))),
        )

https://github.com/gluesql/gluesql/blob/main/test-suite/src/ast_builder/expr/pattern_matching.rs#L69 or

        .filter("c.name = 'Fruit' OR c.name = 'Meat'")

https://github.com/gluesql/gluesql/blob/main/test-suite/src/ast_builder/select.rs#L85

Sure, this worked fine for select(). for update() I tried the other day and was not working.

from gluesql.

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.