I have been using nil to insert NULL values into my Postgres DB. Now when 
0.19.1 has phased out nil \- what to do?

I have tried with empty strings, "NULL", dbNull, etc., but I haven't found a 
solution.
    
    
    import db_postgres
    
    var db = connecToDB()
    
    db.exec(sql("""CREATE TABLE myTable (
                     id  SERIAL PRIMARY KEY,
                     name VARCHAR(50),
                     age INTEGER"""))
    
    discard insertID(db, sql"INSERT INTO myTable (name, age) VALUES (?, ?)", 
"John", 55)
    
    # How to insert a NULL value?
    discard insertID(db, sql"INSERT INTO myTable (name, age) VALUES (?, ?)", 
nil, 55)
    discard insertID(db, sql"INSERT INTO myTable (name, age) VALUES (?, ?)", 
"John", nil)
    
    
    Run

Reply via email to