Could replaced types be pointer types? #1240
Unanswered
preslavrachev
asked this question in
Q&A
Replies: 1 comment 2 replies
-
Technically, it shouldn't matter to SQLBoiler what types you replace with as long as it satisfies the Whether it actually works or not depends on the database driver you use. For example, does the driver allow you to do this? // Imagine users has id, custom_col
row, _ := db.QueryRow("select * from users limit 1")
var id int
var customCol *CustomColStruct
rows.Scan(&id, &customCol) That becomes a double pointer which some drivers may complain about. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I was playing around with type replacements for some of our JSON column, and was curios to figure out, whether the code below would work:
turns out, it does not. From my experiments, it looks like type replacements need a concrete value type, even for nillable fields. I am aware that this is a convention that the the Go team has adopted for types whose zero value could be
NULL
, but, as Russ Cox says, a pointer could do the job equally well, and it has the advantage that one is not leaking SQL-specific types to the rest of the code.So, my question is if it is possible to support pointer types, or if it works already, what is the specific syntax to achieve it?
Beta Was this translation helpful? Give feedback.
All reactions