How/where to create triggers. Can I do that in an annotation?
Tom R.
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()
Mark M.
(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
Nov 2
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
Mark M.
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
Tom R.
My use case is to maintain a reference count on a row
Nov 2
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