fragmatyc / SDFL

Simple Data Fix Language
1 stars 2 forks source link

Delete statement - Using Template or Only If? #5

Closed fragmatyc closed 8 years ago

fragmatyc commented 8 years ago

The current implementation of the DeleteStatement in SDFL is:

delete from MY_TABLE using template
  "Value 1" -> COLUMN_1,
  "Value 2" -> COLUMN_2;

This prevents the user from having a complex where clause. Should we use the only if command like so:

delete from MY_TABLE only if
    COLUMN_1 = "Value 1"
    and COLUMN_2 = "Value 2";
Cpt-xx commented 8 years ago

What would you like to achieve by replacing "using template" with "only if"? What are you trying to express with "using template" and what are you trying to express with "only if"?

fragmatyc commented 8 years ago

A template is a mapping between a value and a column. It's expressed using the arrow operator. You read it by saying "goes in column" or such. The arrow operator points toward the column name showing a kind of a movement of the data from the left side to the right side.

"only if" is a conditional statement with assertions and condition group. It just does not make any sense to have using template in place of only if here.

Cpt-xx commented 8 years ago

In that case, do we want to adopt the Java '==' for equals, as oposed to '=' for assignment, or should we introduce a keyword such as 'eq' to express equality. Now people might get confused as in some languages '=' is used for assignment (such as Java) and in others '=' is used for equality (as in Pascal). I had them mixed up I have to admit.

Using 'eq' would remove all ambiguity in this case.

fragmatyc commented 8 years ago

only if is something I came up to make the where clause more readable. Ex.:

delete from MY_TABLE only if
            MY_COLUMN_1 = "ABC"

Reads: delete from my table only if my column 1 equals ABC. Which sounds perfect to me. Perhaps we could allow both eq and =?

Cpt-xx commented 8 years ago

Since we're operating in the world of Java developers and we're writing a tool intended for Java developers who are not that well versed in SQL (that's the whole purpose of SDFL, right?) I would suggest allowing ' eq ' and ' == ' just to avoid confusion with ' = '-the assignment.

But in the end it remains your call.

fragmatyc commented 8 years ago

Hey Cor, we are not targeting an audience of programmers with specific functions. We should stick to SQL syntax as much as possible, but make it easier to read, less verbose.

One day, we will have to consider the assignation. For now, nothing uses assignation except the arrow operator which reads "put into" ("4" -> MY_COLUMN) for SDFL templates that are mappings between values and columns.

To me, something more readable would be: set myVariable = 10

What do you think? It would stick to something SQL users are into (https://msdn.microsoft.com/en-CA/library/ms189484.aspx)

fragmatyc commented 8 years ago

Reopened a ticket for operators talk. This ticket was simply a mistake as it does not make any sense in SDFL to use a template for conditions.