You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are some basic build-in SQL functions that are not supported by every database in the same way. One example is the version() function. Sqlite does not support it but has sqlite_version(). Another example is now() wich is also not supported by sqlite, instead one has to use CURRENT_TIMESTAMP there.
Expected Behavior
I would like pop to handle these cases for me. One idea I had was to export some constants like pop.Now or pop.Version that one can insert into the query and that would be filled in by the driver accordingly.
E.g.:
c.RawQuery("SELECT ? as version", pop.Version).First(&v))
Actual Behavior
Currently I have to do it similar to:
versionFunc:="version()"ifc.Dialect.Name() =="sqlite3" {
versionFunc="sqlite_version()"
}
/* #nosec G201 - versionFunc is an enum */require.NoError(t, c.RawQuery(fmt.Sprintf("SELECT %s as version", versionFunc)).First(&v))
I can work on this if it is desired to have.
The text was updated successfully, but these errors were encountered:
? is unfortunately reserved for escaped SQL arguments (on a driver level) which makes the proposal difficult to implement. Alternatively, we could expose an interface of "generic" SQL functions such as NOW() or version in a common interface which you could use with fmt.Sprintf. Question is if there is enough overlap in these generic functions to warrant such an interface or if there are really just a few (e.g. NOW()) where this could be used.
sio4
added
proposal
A suggestion for a change, feature, enhancement, etc
s: triage
Some tests need to be run to confirm the issue
labels
Sep 20, 2022
Description
There are some basic build-in SQL functions that are not supported by every database in the same way. One example is the
version()
function. Sqlite does not support it but hassqlite_version()
. Another example isnow()
wich is also not supported by sqlite, instead one has to useCURRENT_TIMESTAMP
there.Expected Behavior
I would like pop to handle these cases for me. One idea I had was to export some constants like
pop.Now
orpop.Version
that one can insert into the query and that would be filled in by the driver accordingly.E.g.:
Actual Behavior
Currently I have to do it similar to:
I can work on this if it is desired to have.
The text was updated successfully, but these errors were encountered: