amphp / sql

Common interfaces for Amp based SQL drivers.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Review to tag

trowski opened this issue · comments

I'd like to tag a version of this library so I can tag new versions of postgres and mysql.

Maybe we should add ResultSet::toArray / ResultSet::getAll as a convenience method? Otherwise, I think I already reviewed the library and haven't found anything I'd change. I didn't review the code more closely, but rather the interfaces.

@kelunik I think those should be separate functions. Perhaps as Amp\Iterator::toArray() and getAll().

Right, my concern is the interfaces more than the code. Code issues we can always fix later.

If @prolic thinks it looks good I'll tag then.

On it, I'll review right now

PooledResultSet

in Mysql: public function getFields(): Promise
in Postgres: public function getFieldCount(): int

Is it possible to unify this and have both methods in SQL interface?

Statement

in Mysql: public function getFields(): Promise; - not possible to add to postgres?
public function bind($paramId, $data); - not possible to add to postgres?
public function reset(): Promise; - not possible to add to postgres?

getFields() could potentially be part of the interface, but the information returned is unlikely to match, so I hesitate to make that part of a common interface.

getFields() could potentially be part of the interface, but the information returned is unlikely to match, so I hesitate to make that part of a common interface.

Okay

Statements in postgres do not support binding values, so bind() and reset() are not necessary.

\Amp\Mysql\DataTypes - can we move that to Internal namespace? I don't think it should be used in userland.

other then what I noted above, I can't find anything more. So if getFieldCount() can be added to SQL, would be fine, otherwise just tag it.

DataTypes can be used when examining values returned from getFields(), etc. So there is reason to have it in the public namespace. The functions are unlikely to change anyway, so I'm not concerned about it being in the public API.

@trowski Amp\Iterator::toArray() won't support the custom parameter to getCurrent(). If we don't want convenience methods, maybe we should remove the fetch type, too? After all, a consumer will likely convert them to a proper value object anyway.

Right, forgot about the fetch type parameter. Well a function in this library would do as well.

Generally the fetch type isn't needed, however if a result has fields with the same name it can matter. Do we care about this case? I've never used it, and queries can always alias field names.

Right, I'd always go with aliasing in that case, so let's drop it?