Search code examples
ponyorm

Pony ORM PostgreSQL Point type


Is it possible to create a data type for the geometric point type from postgres? For the point type, it is just a pair of numbers.


Solution

  • Pony doesn't have native support for these exotic kind of types.
    But you can specify sql_type like this:

    b = Required(str, sql_type='point')
    

    Which gives you SQL:

    CREATE TABLE "A" (
      "id" INTEGER PRIMARY KEY AUTOINCREMENT,
      "b" POINT NOT NULL
    )
    

    I just tested it in SQLite and transaction was succesful (even SQLite doesn't support point type). But you should do your personal workaround for validating point data you are sending to database.