Skip to content

SqlConnection.query caches at the class level, not the instance level #14077

@sfc-gh-jkinkead

Description

@sfc-gh-jkinkead

Checklist

  • I have searched the existing issues for similar issues.
  • I added a very descriptive title to this issue.
  • I have provided sufficient information below to help reproduce this issue.

Summary

SqlConnection uses the field self._connection_name as the "per instance" portion of a cache key. However, the connection factory allows overriding any connection parameters when creating - which means that you can have multiple connections with different settings sharing a cache key.

SqlConnection should likely add a dummy self-like argument to the inner query function to ensure each instance has its own cache.

Reproducible Code Example

Steps To Reproduce

No response

Expected Behavior

No response

Current Behavior

No response

Is this a regression?

  • Yes, this used to work in a previous version.

Debug info

  • Streamlit version:
  • Python version:
  • Operating System:
  • Browser:

Additional Information

No response

Metadata

Metadata

Labels

feature:cacheRelated to `st.cache_data` and `st.cache_resource`feature:connectionsRelated to `st.connection` and connections modulepriority:P3Medium prioritystatus:confirmedBug has been confirmed by the Streamlit teamtype:bugSomething isn't working as expected

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions