Closed lookharm closed 4 years ago
@qiangxue The program that I wrote use pgx driver (https://github.com/jackc/pgx) for PostgreSQL. I found the dbx can use pgx driver from here. https://github.com/go-ozzo/ozzo-dbx/blob/c0868b7fa469684fd21331c4b0c334d732d039f9/db.go#L75-L82 When I try to insert a new record with the Insert() method like the document page. The code as below.
err := db.Model(&customer).Insert()
I encountered some error like "LastInsertId is not supported by this driver"
I think the function insertAndReturnPK() should also check for pgx driver. Both pgx and postgres driver use for PostgreSQL, but PostgreSQL doesn't support for LastInsertID(). https://github.com/go-ozzo/ozzo-dbx/blob/c0868b7fa469684fd21331c4b0c334d732d039f9/model_query.go#L107-L114
[sory for my poor English skill]
Thank you for reporting this issue! Could you verify the fix?
Yes, it works. :thumbsup:
@qiangxue The program that I wrote use pgx driver (https://github.com/jackc/pgx) for PostgreSQL. I found the dbx can use pgx driver from here. https://github.com/go-ozzo/ozzo-dbx/blob/c0868b7fa469684fd21331c4b0c334d732d039f9/db.go#L75-L82 When I try to insert a new record with the Insert() method like the document page. The code as below.
I encountered some error like "LastInsertId is not supported by this driver"
I think the function insertAndReturnPK() should also check for pgx driver. Both pgx and postgres driver use for PostgreSQL, but PostgreSQL doesn't support for LastInsertID(). https://github.com/go-ozzo/ozzo-dbx/blob/c0868b7fa469684fd21331c4b0c334d732d039f9/model_query.go#L107-L114
[sory for my poor English skill]