Closed anuraaga closed 1 year ago
To pass a custom column list to insert or update query, you can use ColumnList
:
I'll add this to wiki.
Thanks @go-jet - would it be possible to use that type in the function definitions? I think it can be confusing to use the API when it references the internal instead of public type there.
We can't use ColumnList
in definition because UPDATE
should work with single Column
, comma separated list of columns and ColumnList
. Now, we could expose jet.Column
, but I don't see how this type would be ever used.
@go-jet I found another API that seems to use public types, Statement.Rows()
returns jet.Rows
(I can't pass Statement
either for similar reason). I can't pass this to another function because jet.Rows
is internal. Is there an alternative type for this? In general I suspect there will be less sharp edges if the public API was audited to remove all the internal types somehow.
Yeah, it seems jet.Rows
is not exposed. Contributions are welcomed.
Statement
is exposed here.
@go-jet
Wouldn't it be better to expose all the internal APIs?
If I understand it correctly, doing so would enable the users of this library to write their own implementations of given interfaces, rather than relying on and waiting for some types being implemented in go-jet
.
I think I'm running into this with some other types.
While trying to create a simple SELECT
query that takes in a variable to equal check against the lastname
field the internal jet package is imported.
This prevents the code from working at all due to the following error:
app.go:10:2: use of internal package github.com/go-jet/jet/v2/internal/jet not allowed
stmt := Users.SELECT(Users.AllColumns).FROM(Users).WHERE(Users.Lastname.LIKE(jet.String("")))
Do you have any way around that besides fixing this in the jet repo?
String
is already exported. You are importing the wrong package.
You need to import a dialect-specific package. For instance: github.com/go-jet/jet/v2/postgres
String
is already exported. You are importing the wrong package. You need to import a dialect-specific package. For instance:github.com/go-jet/jet/v2/postgres
Thanks for the help! I just realized that as well as I don't use the dot imports as shown in the READMe at the moment.
I have run into the same problem. I might try creating a pull request unless some is working on this.
Rows
is now exposed on master branch.
Fixed with Release v2.10.1.
Describe the bug A clear and concise description of what the bug is.
There are some public APIs that expose internal tyeps, for example
Table.INSERT
https://github.com/go-jet/jet/blob/master/mysql/table.go#L10
jet.Column
is internal.Expected behavior
All public APIs should only use public types. For example, it doesn't seem to be possible for a user to pass in a slice of columns with the current signature.