Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AfterGet / AfterSelect #48

Open
robfig opened this issue Feb 2, 2013 · 2 comments
Open

AfterGet / AfterSelect #48

robfig opened this issue Feb 2, 2013 · 2 comments

Comments

@robfig
Copy link

robfig commented Feb 2, 2013

How do you feel about adding a hook that runs after loading an entity? I use this feature (in Gorp) presently for two things:

  1. Eagerly loading relations
  2. Setting Go properties that do not map directly to a SQL data type -- for example, time.Time does not work with sqlite3 -- to work around that, in BeforeSave I set a TimeStr string field on the model, and in AfterGet I parse that property back into the time.Time field.

Although, it looks like there is no way to issue queries from the hook, so use case (1) would not apply anyway.

@eaigner
Copy link
Owner

eaigner commented Feb 2, 2013

ad 2) you can map Go to DB specific types with the dialect interface, no hooks required

PS: there's actually a sqlite dialect implementation, it's just not on the main branch since some methods are missing, and need to be implemented with workarounds (sqlite doesn't support all sql commands).

@eaigner
Copy link
Owner

eaigner commented Feb 2, 2013

ad 1) should be trivial to add

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

No branches or pull requests

2 participants