Skip to content
This repository has been archived by the owner on Jan 10, 2023. It is now read-only.

Consider accepting a single row when calling values() #213

Open
valioDOTch opened this issue Jun 13, 2017 · 2 comments
Open

Consider accepting a single row when calling values() #213

valioDOTch opened this issue Jun 13, 2017 · 2 comments

Comments

@valioDOTch
Copy link

valioDOTch commented Jun 13, 2017

Enhancement suggestion: I have stumbled multiple times over the fact, that values expects an array and can't handle a call where I provide a single row (which gives the not-so-descriptive error "rows.some is not a function").

Said differently: I would expect the following the work
let pendingRequestTable = connection.getSchema().table("PendingRequests"); let data = {url,method,body, timestamp: (new Date()).valueOf()}; let requestRow = pendingRequestTable.createRow(data); connection.insertOrReplace().into(pendingRequestTable).values(requestRow).exec();

@valioDOTch valioDOTch changed the title Cks Consider accepting a single row when calling values() Jun 13, 2017
@freshp86
Copy link
Contributor

freshp86 commented Jun 13, 2017

This sounds reasonable. When we first designed this API we wanted (and still do) to avoid runtime type checking (like detecting if an array or a single value was passed). Perhaps a different way to address the issue is to add a value() method, that accepts a single value and leave values() semantics as is.

FWIW, another enhancement I've thought about (but never got to implement), is to stop requiring calling code to call createRow() first, instead call this internally. So in your example you would be passing data straight to values().

@valioDOTch
Copy link
Author

I assumed that performance might be an issue for this decision.
I think the "value" approach would be a possibility (albeit being at odds with SQL syntax).

I would be in favour of omitting the createRow call.
I haven't met a case yet where the explicit call would add further value.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants