Office Hours — Today, November 2

Thursday, October 31

Mark M.
has entered the room
Mark M.
turned on guest access
Nov 2
4:15 PM
Tom R.
has entered the room
Tom R.
Hi Mark
Mark M.
hello, Tom!
how can I help you today?
Tom R.
Quick question for you regarding Room.
How/where to create triggers. Can I do that in an annotation?
Or should I do that in a onCreate callback in code?
Mark M.
I don't recall Room having support for triggers -- you will probably need to do what you describe, registering them yourself via SupportSQLiteDatabase in onCreate()
(and also in a relevant Migration, if applicable)
Tom R.
ok - that's the best I could find. Seems like a glaring omission from Room
4:20 PM
Mark M.
I'm scanning the issue tracker, and I'm not seeing an obvious feature request for it
Tom R.
thanks for your help - I'll run with that and see how it goes
Mark M.
unfortunately, a simple search on "room trigger" turns up a lot of hits, so it might be there and I'm just not picking it up from the returned issue titles
if you have a good use case for triggers with Room, file a feature request -- they are fairly responsive, but having a concrete scenario helps
Tom R.
There's probably not much value that Room could add, beyond compile time checking
My use case is to maintain a reference count on a row
4:25 PM
Mark M.
so, modifications to TableA affect some referenceCount column in TableB?
Tom R.
right
Mark M.
in theory, Room could abstract that away and handle setting up the triggers for you, but I suspect that's too niche of a use case for them to want to spend the time
Tom R.
thanks
Tom R.
has left the room
4:55 PM
Mark M.
turned off guest access

Thursday, October 31

 

Office Hours

People in this transcript

  • Mark Murphy
  • Tom Riddle