Closed t-ae closed 3 years ago
MySQLRow does have this method: https://github.com/vapor/mysql-nio/blob/master/Sources/MySQLNIO/MySQLRow.swift#L29
You will need to cast the SQLRow to MySQLRow to access it.
PostgreSQL does not support this type of column name disambiguation so it's not something we can generalize to SQLKit.
There seems to be no way to decode models from
MySQLRow
with specified table name in Vapor 4. (In Vapor 3 I often used this method. https://github.com/vapor/mysql-kit/blob/3.3.0/Sources/MySQL/Connection/MySQLConnection.swift#L66-L69)I have raw query like below:
It returns columns like
table1.id
,table2.id
... There are columns with same name but they can be distinguished with table name.MySQLRow
conveys this information, but all itsdecode
methods come fromSQLRow
protocol and they don't consider table names. Thus they can't distinguishtable1.id
andtable2.id
, and we get wrong result.MySQLRow
should have its own decoding methoddecode(model: Decodable.Type, table: String)
. I think it can be done by creatingMySQLRowDecoder
that imitatesSQLRowDecoder
, but first I want your opinion if this design is good or not. I use only MySQL so I'm not sure if this can be generalized to other RDBMSs.