Giter VIP home page Giter VIP logo

Comments (4)

pawurb avatar pawurb commented on May 30, 2024 1

@andyatkinson thanks for pointing out. I've added a way to specify default schema via ENV here: pawurb/ruby-pg-extras@43f2d2b it's now out as 5.3.1. Please confirm if it resolves the issue.

from rails-pg-extras.

andyatkinson avatar andyatkinson commented on May 30, 2024 1

Hi @pawurb Nice, that fixes it. Here's my sample app for the book with a PR related to this gem update, and then invocations of the commands with the updated gem version:
andyatkinson/rideshare#162

I had hoped I could add the ENV var to the .env file and it would "just work", but that wasn't the case. I imagine that would need some more work? Setting the env var in the terminal though before I invoke the commands works fine.

This fixes it for diagnose too, we can see the schema is included in the generated SQL queries. Here's an example:

SELECT
....
FROM pg_stat_user_indexes ui
....
AND schemaname = 'rideshare'
...

Thanks!

from rails-pg-extras.

drnic avatar drnic commented on May 30, 2024

Ooh, I found the ruby-pg-extras gem, and figured out I can pass args: {schema: "other_schema"} to the various helpers.

RailsPgExtras.cache_hit(args: {schema: "other_schema"})

I'll create a PR for this for the docs.

from rails-pg-extras.

andyatkinson avatar andyatkinson commented on May 30, 2024

@pawurb @drnic Hello! For Rideshare, it uses a custom rideshare schema. I see I can run this code that @drnic mentioned (and hat tip @DanielaBaron for noticing this), but is there a way to make this the default via an initializer option? I am digging into the initializer now but didn't immediately see how to set a schema. I did configure an ENV var for rails-pg-extras. Unfortunately even though the default schema for the PostgreSQL user I'm connecting as (which is rideshare) wasn't used, and public was still used. I've removed the public schema from that application database following "Safe schema patterns" best practices.

Expected: The default schema for the PostgreSQL user is used. I've removed
Actual: Queries use the public schema when running bin/rails pg_extras:cache_hit regardless of user's default schema

bin/rails runner 'RailsPgExtras.table_cache_hit(args: { schema: "rideshare" })'

from rails-pg-extras.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.