-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add missing parameters to Avram::Database.truncate
method
#984
Conversation
Missed these in commit 97a2cd9.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops! 😅 Guess I missed these too... I thought we had specs around truncate, but maybe not? Would you be able to add a spec in just so we have these accounted for in case there's other changes?
avram/spec/avram/queryable_spec.cr Lines 1244 to 1266 in 0b9797b
There's none for |
Line 13 here produces same error in CockroachDB: avram/src/avram/spec_helper.cr Lines 10 to 15 in 0b9797b
Should the call to |
That probably doesn't matter much for the specs, I would assume. Does Cockroach require this to get changed in order to work? |
Yes. |
Gotcha... hmm 🤔 Would it be weird to have a property on the database that decides if it should have this or not? Maybe it's time to think about an databases.each do |db|
db.truncate(restart_identity: db.engine.postgresql?)
end Or does that sound like too much for this case? Maybe a simple solution is just passing in that option? I'm not sure if there would be a time where you use postgres and don't want the |
I'm thinking more along the lines of checking for "no_restart_identity" tag on the spec, and setting
If we do this, we should not need to set I believe this raises the question of the broader support for other DB engines as discussed in #924 (comment). |
Ok. Maybe we just add the tag in as a temporary workaround for now with a
Yeah, I still am of the feeling that I would love to avoid all the extra work of supporting extra engines. It's a bit frustrating that Cockroach says it's postgres compatible, but seems to have an asterisk. The tough part here is that we currently have no way to test if a change will break Cockroach. But I guess we're at the point that we either need to say we can't support it at all, or bite the bullet and just start supporting more things. So I guess what I'm saying is, let's just hack around this issue for now so you're not blocked on anything, then we can start planning out a path to add more support for other engines as well as figuring out a way to test this to prevent this issue down the road. |
Sure, will see what I can come up with.
Me too. I figure a shard that extends Avram (mostly via monkey-patching), purposely for Cockroach DB (or whatever engine anyone needs supported) should do the trick. These could be maintained by persons outside the core team. I added something similar in Lucille (GrottoPress/lucille@12cb929), but removed it after the relevant issues were fixed in #980. The idea is that any issues with any of the DBs would get patched in these shards (which should have shorter release cycles), and may or may not be patched upstream. In any case, for as long as an application does
I have added Lucky/Avram
From what I understand from their end, some things are difficult to implement because of the very nature of Cockroach's architecture. The few issues in Avram had to do with spec and migration helpers. It works very well otherwise; one could always drop down to raw SQL if desired.
Don't worry about me 😃. I tend to find my way somehow. Whatever we decide should work well for the community at large. |
Calling |
Yeah, you can do your own manual truncate in the specs, but it's currently setup to do it automatically for you so you don't have to call it on every spec. This was added in as part of a way to make specs run faster. I think if we took it out, then you'd have to decide how to clear your data between specs always whether that's with truncate or with transactional rollbacks. That may complicate things more, I think. |
Adds support for restart identity and cascade during transactional specs, using tags.
I think this is good, so I'm just gonna merge, but if there's more updates we need for this, let me know. Thanks @akadusei! |
Missed these in #980