Add postgres support #135

Merged
konrad merged 26 commits from jtojnar/api:pgsql into master 2020-02-16 21:42:05 +00:00
3 changed files with 11 additions and 11 deletions
Showing only changes of commit 520501edd0 - Show all commits

View File

@ -8,7 +8,7 @@
updated: 1543626724
- id: 2
text: 'task #2 done'
done: 1
done: true

Would it make sense to use boolean in DDL instead? It seems to be supported in all the languages (even though outside of Postgres only as aliases):

SQLite

sqlite> create table foo(b boolean);
sqlite> insert into foo values(true);
sqlite> select * from foo;
1

PostgreSQL

postgres=# create table foo(b boolean);
CREATE TABLE
postgres=# insert into foo values(true);
INSERT 0 1
postgres=# select * from foo;
 b 
---
 t
(1 row)

MariaDB

MariaDB [test]> create table foo(b boolean);
Query OK, 0 rows affected (0.026 sec)

MariaDB [test]> insert into foo values(true);
Query OK, 1 row affected (0.004 sec)

MariaDB [test]> select * from foo;
+------+
| b    |
+------+
|    1 |
+------+
1 row in set (0.000 sec)
Would it make sense to use `boolean` in DDL instead? It seems to be supported in all the languages (even though outside of Postgres only as aliases): ### SQLite ``` sqlite> create table foo(b boolean); sqlite> insert into foo values(true); sqlite> select * from foo; 1 ``` ### PostgreSQL ``` postgres=# create table foo(b boolean); CREATE TABLE postgres=# insert into foo values(true); INSERT 0 1 postgres=# select * from foo; b --- t (1 row) ``` ### MariaDB ``` MariaDB [test]> create table foo(b boolean); Query OK, 0 rows affected (0.026 sec) MariaDB [test]> insert into foo values(true); Query OK, 1 row affected (0.004 sec) MariaDB [test]> select * from foo; +------+ | b | +------+ | 1 | +------+ 1 row in set (0.000 sec) ```

I've since changed how the tables are initialized and let xorm handle it based on the type of the field in Go. It seems like for postgres, it creates boolean table definitions. We could change the fixtures back to true/false values now, but the underlying data types in postgres were still tinyints which need either 0 or 1.

I've since changed how the tables are initialized and let xorm handle it based on the type of the field in Go. It seems like for postgres, it creates boolean table definitions. We could change the fixtures back to `true`/`false` values now, but the underlying data types in postgres were still `tinyint`s which need either `0` or `1`.

Reverted it since it works with postgres after the other fixes.

Reverted it since it works with postgres after the other fixes.
created_by_id: 1
list_id: 1
index: 2

View File

@ -1,7 +1,7 @@
-
team_id: 1
user_id: 1
admin: 1
admin: true
created: 0
-
team_id: 1

View File

@ -3,7 +3,7 @@
username: 'user1'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user1@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
-
@ -43,55 +43,55 @@
username: 'user6'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user6@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 7
username: 'user7'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user7@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 8
username: 'user8'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user8@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 9
username: 'user9'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user9@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 10
username: 'user10'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user10@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 11
username: 'user11'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user11@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 12
username: 'user12'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user12@example.com'
is_active: 1
is_active: true
updated: 0
created: 0
- id: 13
username: 'user13'
password: '$2a$14$dcadBoMBL9jQoOcZK8Fju.cy0Ptx2oZECkKLnaa8ekRoTFe1w7To.' # 1234
email: 'user14@example.com'
is_active: 1
is_active: true
updated: 0
created: 0