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

fix: rel_sql(rel, "{{sql}}") works even on a read-only database #138

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

Tmonster
Copy link
Contributor

@Tmonster Tmonster commented Apr 3, 2024

If a user attempts to query a read only database with rel_sql they will encounter an error. This is because rel_sql creates a view with name _.

The fix is to make this a temporary view. If the user still tries to create a table with create table as (select * from _) an error should still be thrown

Fixes https://github.com/duckdblabs/duckdb-internal/issues/1721

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 79.73%. Comparing base (0118ae4) to head (ed32009).

❗ Current head ed32009 differs from pull request most recent head 3bb53c3. Consider uploading reports for the commit 3bb53c3 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #138      +/-   ##
==========================================
+ Coverage   79.70%   79.73%   +0.02%     
==========================================
  Files         108      108              
  Lines        3711     3711              
==========================================
+ Hits         2958     2959       +1     
+ Misses        753      752       -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@krlmlr krlmlr changed the title bug fix: rel_sql(rel, "{{sql}}") should work even on a read only database fix: rel_sql(rel, "{{sql}}") works even on a read-only database Apr 24, 2024
@krlmlr krlmlr merged commit 901d38d into duckdb:main Apr 29, 2024
21 of 23 checks passed
@krlmlr
Copy link
Collaborator

krlmlr commented Apr 29, 2024

Thanks!

Comment on lines +327 to +329
bool replace = true;
bool temp = IsReadOnly();
CreateView(name, replace, temp);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Tmonster: I realized too late that this patches the duckdb sources. Has this been upstreamed by now? Do you want to?

I can work around with a patch file for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

has not been upstreamed yet, and might not be until after v1.0 comes out. I think a patch file in duckdb-r is the way to go for now. I will still create an upstream PR though so you can eventually remove that patch.

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

Successfully merging this pull request may close these issues.

3 participants