typhon-project / typhonql

Typhon Query Language
Eclipse Public License 2.0
4 stars 1 forks source link

Date conversion problem #23

Closed benatspo closed 4 years ago

benatspo commented 4 years ago

Using TyphonQL eclipse plugin, I tried to insert a new entity instance, containing a Date attribute. According to the grammar, I used the following syntax for the insert query : insert CreditCard {id: 1, number: 1, expiryDate: "2021-12-31"} The insert was successful, and I'm able to find the added instance in the database, using an application connected to the database. image

But, when using TyphonQL editor to select the added instance, I have an exception. Query: from CreditCard c select c Exception:

"Error: IllegalArgumentException("java.sql.exception", "Cannot convert Java object to Rascal value")

Here is the corresponding TML file, containg the definition of the entity and the Date type:

datatype Date
datatype String

entity CreditCard {
    id : String
    number : String
    expiryDate : Date
}

relationaldb RelationalDatabase {
    tables {
        table {
            CreditCard : CreditCard
            idSpec ("CreditCard.number")
        }
    }
}
pinoval commented 4 years ago

The syntax for inserting the date was wrong. It should have been:

insert CreditCard {id: 1, number: 1, expiryDate: $2021-12-31$}

However, there were bugs when mapping from the TyphonQL insertion query to the relational one, when there were dates involved. We thus fixed them on commit ebecb9bf8a7a9e4eb631231e9c99a30d1f5212dd . This works for relational databases, we have opened issue #33 to add support for dates in MongoDB.