Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding optional constructor to WhereClause #27

Open
blackjack26 opened this issue Sep 14, 2016 · 7 comments
Open

Adding optional constructor to WhereClause #27

blackjack26 opened this issue Sep 14, 2016 · 7 comments

Comments

@blackjack26
Copy link
Collaborator

When creating a WhereClause object, to make syntax shorter there could be an optional constructor in which you pass in some sort of string that sets the internal variables of the object.

Ex:

// Current Syntax
WhereClause wc = new WhereClause();
wc.name = "df";
wc.operator = WhereClause.Operators.NOT_EQUAL;
wc.value = "true";
wc.conditional = WhereClause.CONDITIONALS.AND;

// New Syntax
WhereClause wcNew = new WhereClause("AND df <> true");
@Corls
Copy link
Collaborator

Corls commented Sep 14, 2016

That kinda defeats the point of WhereClause though...

@Corls
Copy link
Collaborator

Corls commented Sep 16, 2016

oh oh oh! Here's one. Okay, instead of making it an optional constructor, we instead update the SqlStatement to contain a function "where(String clause)". This way you don't need to go SqlStatement.where(new WhereClause('AND df <> true')); but SqlStatement.where('AND df <> true'));

@Corls
Copy link
Collaborator

Corls commented Sep 16, 2016

or make the optional constructor package-private so SqlStatement.where("AND df <> true"); reads where(String clause) { where.add(new WhereClause(clause); } taking that extra step out for the developer who is using this method, but also allows for the flexibility of needing the constructor after all, in which case you would add "public" in front of the optional constructor.

@Corls
Copy link
Collaborator

Corls commented Sep 16, 2016

With either idea, we would be able to make the SqlStatement.where be able to create several where clauses at once, meaning someone could literally type out the whole where WHERE df <> true AND cf = true AND tid = 1 and it'd generate all 3 clauses.

@Corls
Copy link
Collaborator

Corls commented Sep 16, 2016

I was just making a quick scratch up to see how this would look like and realized that these ideas have no way of conveying the valueDataType and thus puts the whole idea on hold until it is worked out a clean, non-obtrusive way to declare the type.

@Corls
Copy link
Collaborator

Corls commented Sep 16, 2016

Meaning, the code for the constructor & function will be in there on my next commit, but are commented out.

@Corls
Copy link
Collaborator

Corls commented Sep 19, 2016

Or, instead of a constructor, we could have a "parse" function, so it's like "WhereClause.parse(String clause)"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants