Giter Site home page Giter Site logo

Make Expression into an interface about dibi HOT 6 CLOSED

dakujem avatar dakujem commented on June 12, 2024 1
Make Expression into an interface

from dibi.

Comments (6)

milo avatar milo commented on June 12, 2024 1

I don't think that expression should be an interface as is. Expression represents Dibi specific syntax. If so, an interface should say that object can be converted into Dibi Expression e.g. via method function toDibiExpression(): Expression.

from dibi.

dakujem avatar dakujem commented on June 12, 2024

I don't see how that is different. Your object would have to return an instance of "dibi specific syntax" anyway and it would achieve the same. But I would be comfortable with that too, anything is better than inheriting from internal objects, that tend to become final, private and such...

from dibi.

dg avatar dg commented on June 12, 2024

Why do you specifically need it?

from dibi.

dakujem avatar dakujem commented on June 12, 2024

I'm writing a convertor that converts key-value arrays to conditions, agnostic of the storage backend.

For SQL, I'm trying to use Dibi. One of the objects I internally use is a "self-unpackable" condition used on both Fluent like this $expression($fluent) as a decorator, and in "regular sql" with %ex modifier.

With Dibi as it is, I need to either extend Expression or use a workaround to support both, neither being an elegant solution.

from dibi.

dg avatar dg commented on June 12, 2024

And why can't the converter create a Dibi\Expression object?

from dibi.

dakujem avatar dakujem commented on June 12, 2024

At the time of writing, I had a syntax tree composed of backend-agnostic nodes. I intended for these nodes to be instances of Expression, but I since scraped the idea and now use a tree traversal algo to converted the structure to a structure of nested Expressions. The downside of this is one more traversal.

This issue was meant to future-proof extensibility options with similar use cases, but I'm fine with the current state for now.

from dibi.

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.