:mega: :kodee-welcoming: Help us name a new DSL fe...
# exposed
c
📣 kodee welcoming Help us name a new DSL feature! 📊 We're working on supporting the MERGE command and we'd appreciate your input. Our goal is to keep the syntax as close to SQL as possible, while still providing you with an easily readable DSL experience. Here's an example of a merge SQL statement:
Copy code
MERGE INTO target_table AS t
USING source_table AS s
ON s.id = t.id
WHEN NOT MATCHED THEN
  INSERT (id, name, amount)
  VALUES (s.id, s.name, s.amount)
WHEN MATCHED AND s.amount < 42 THEN
  UPDATE SET amount = t.amount + s.amount
WHEN MATCHED THEN
  DELETE;
Please react with the option below that reads better to you, or leave a comment 🧵 with an alternative name 🤔 Here's DSL option 1️⃣:
Copy code
TargetTable.mergeFrom(SourceTable) {
    insertWhenNotMatched {
        // insert values
    }
    updateWhenMatched(and = SourceTable.amount less 42) {
        // update values
    }
    deleteWhenMatched()
}
And here's DSL option 2️⃣:
Copy code
TargetTable.mergeFrom(SourceTable) {
    whenNotMatchedInsert {
        // insert values
    }
    whenMatchedUpdate(and = SourceTable.amount less 42) {
        // update values
    }
    whenMatchedDelete()
}
Thanks in advance for your input thank you color
1️⃣ 2
2️⃣ 11
d
I never used the merge statement, so please take my preference with a grain of salt. But reading the two options the second one sounds more intuitive as I would go through the statements from top to bottom and would “pattern match” the statement I am looking for by the more important aspect first, namely the condition. The first option feels like it is more tailored to the one writing the statement as they know what they would like to do. Considering that code should mainly be more easy to read (IMHO) than to write, I would prefer option 2️⃣
thank you color 1