{"id":14969805,"url":"https://github.com/calin-ciobanu/ignorable_columns","last_synced_at":"2025-04-19T18:08:03.325Z","repository":{"id":56877334,"uuid":"125791406","full_name":"calin-ciobanu/ignorable_columns","owner":"calin-ciobanu","description":"Convient way to optimize rails queries by only loading required columns from db","archived":false,"fork":false,"pushed_at":"2018-05-31T04:35:11.000Z","size":22,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-16T13:35:44.408Z","etag":null,"topics":["activerecord","graphql","optimization","queries","rails"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/calin-ciobanu.png","metadata":{"files":{"readme":"README.rdoc","changelog":null,"contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-19T02:36:07.000Z","updated_at":"2018-07-12T04:34:30.000Z","dependencies_parsed_at":"2022-08-20T22:00:34.375Z","dependency_job_id":null,"html_url":"https://github.com/calin-ciobanu/ignorable_columns","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calin-ciobanu%2Fignorable_columns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calin-ciobanu%2Fignorable_columns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calin-ciobanu%2Fignorable_columns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/calin-ciobanu%2Fignorable_columns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/calin-ciobanu","download_url":"https://codeload.github.com/calin-ciobanu/ignorable_columns/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249758291,"owners_count":21321493,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["activerecord","graphql","optimization","queries","rails"],"created_at":"2024-09-24T13:42:25.136Z","updated_at":"2025-04-19T18:08:03.275Z","avatar_url":"https://github.com/calin-ciobanu.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= IgnorableColumns\n\nMotivation is to allow ignoring certain columns both at model level (columns/attributes) as well as database queries level.\nIt works with +includes+ and +eager_load+ as well as simple queries.\n\nTested on +Rails4+, should work on +Rails3+. Not tested on +Rails5+.\n\n== Example Usage\n\n  class Topic \u003c ActiveRecord::Base\n    ignore_columns :name, :body, :timezone\n    ignore_columns_in_sql # optional, recommended for better performance\n  end\n\n+ignore_columns+ must be defined before using +ignore_columns_in_sql+.\n\nTo temporarily use the ignored columns:\n\n  Topic.including_ignored_columns.where(name: 'Data Rocks')\n  Topic.including_ignored_columns(:name).where(name: 'Data Rocks')\n\nFor use with relations see below example:\n\n=== Has many\n\n  class Topic \u003c ActiveRecord::Base\n    ignore_columns :name, :body, :timezone\n    ignore_columns_in_sql # optional, recommended for better performance\n\n    belongs_to :author\n    belongs_to :author_with_location, class_name: Author.including_ignored_columns(:location).name, foreign_key: 'topic_id'\n  end\n\n  class Author \u003c ActiveRecord::Base\n    ignore_columns :location, :updated_at\n    ignore_columns_in_sql # optional, recommended for better performance\n\n    has_many :topics\n    has_many :topics_with_body, class_name: Topic.including_ignored_columns(:body).name\n    has_many :topics_with_all, class_name: Topic.including_ignored_columns.name\n  end\n\n  Author.last.topics_with_body\n  Topic.where(name: 'MyTopic').author_with_location\n  Author.includes(:topics_with_all).last.topics_with_all\n  Author.eager_load(:topics_with_all).last.topics_with_all\n\n=== Self Referential\n\n  class Topic \u003c ActiveRecord::Base\n    ignore_columns :name, :body, :timezone\n    ignore_columns_in_sql # optional, recommended for better performance\n\n    belongs_to :parent_topic, class_name: Topic.name\n    has_many :child_topics, class_name: Topic.name, foreign_key: 'parent_id'\n\n    belongs_to :parent_topic_with_all, class_name: Topic.including_ignored_columns.name\n    has_many :child_topics_with_all, class_name: Topic.including_ignored_columns.name, foreign_key: 'parent_id'\n  end\n\n  Topic.where(name: 'MyTopic').child_topics_with_all\n\n=== Many to many\n\n  class Topic \u003c ActiveRecord::Base\n    ignore_columns :name, :body, :timezone\n    ignore_columns_in_sql # optional, recommended for better performance\n\n    has_many :author_topics\n    has_many :authors, through: :author_topics\n  end\n\n  class Author \u003c ActiveRecord::Base\n    ignore_columns :location, :updated_at\n    ignore_columns_in_sql # optional, recommended for better performance\n\n    has_many :author_topics\n    has_many :topics, through: :author_topics\n  end\n\n  class AuthorTopic \u003c ActiveRecord::Base\n    belongs_to :author\n    belongs_to :topic\n\n    belongs_to :authors_with_location, class_name: Author.including_ignored_columns(:location).name, foreign_key: 'author_id'\n  end\n\n  Topic.where(name: 'MyTopic').last.authors_with_location\n\n== Limitations\n- does not support has and belongs to many relations\n- does not support polymorphic relations\n- because of the ActiveRecord implementation when using +count+ it should be used as \u003ctt\u003ecount(:all)\u003c/tt\u003e\n(else a middleware could be implemented but it is out of the scope of this gem)\n\n== TO DO\n1. specs for relations other than has many\n2. specs for concurrency\n3. support for rails 5\n4. examples (and / or another gem) for use with graphql\n\nInspired by https://github.com/nthj/ignorable\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalin-ciobanu%2Fignorable_columns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcalin-ciobanu%2Fignorable_columns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcalin-ciobanu%2Fignorable_columns/lists"}