leikind / wice_grid

A Rails grid plugin to create grids with sorting, pagination, and (automatically generated) filters
MIT License
537 stars 215 forks source link

Issue with order #154

Closed afdev82 closed 8 years ago

afdev82 commented 10 years ago

When I try to order a field of my Configurations::Configuration model, I get the following error:

PG::UndefinedColumn: ERROR:  column configurations.configurations does not exist
LINE 1: ... FROM "configurations"."configurations"  ORDER BY "configura...
                                                             ^
: SELECT  "configurations"."configurations".* FROM "configurations"."configurations"  ORDER BY "configurations"."configurations" asc LIMIT 20 OFFSET 0

I initialized the grid simply in this way:

@configurations = initialize_grid(Configurations::Configuration)

In my view I have:

grid(@configurations, allow_showing_all_records:  false) do |g|
  g.column name: 'Project ID',
           attribute: 'configuration_id' do |configuration|
    configuration.configuration_id
  end
  g.column name: 'Project name',
           attribute: 'name' do |configuration|
    configuration.name
  end
end

Thank you in advance!

afdev82 commented 10 years ago

The query string is:

grid[order]=configuration_id&grid[order_direction]=asc

If I submit this:

grid[order]=configurations.configuration_id&grid[order_direction]=asc, it works
leikind commented 9 years ago

Please give more info about your data model

afdev82 commented 9 years ago

I have the "Configurations::Configuration" class, that represents a "configuration" of one product in a "configurator" web application. This is the class without its methods:

class Configurations::Configuration < ActiveRecord::Base
  include GettersHelper
  include JsHelper

  self.primary_key = 'configuration_id'
  self.table_name  = 'configurations.configurations'

  serialize :included, JSON
  serialize :restricted, JSON

  <private code>
leikind commented 9 years ago

WiceGrid is likely not to work correctly with posgresql tables in non-public schemas, i.e. with table names like 'configurations.configurations'. Cannot say for sure because I don't use Postgresql, and all users of WiceGrid with posgresql use the public schema, a flat list of tables.

afdev82 commented 9 years ago

Ok, thanks!
Do you think is it possible to make a wrapper or initializer to change the behaviour of WiceGrid to handle this?

leikind commented 9 years ago

I am pretty sure it would be not that difficult to solve this problem, unfortunately at present I cannot say when I'll do it. But I will accept pull requests :-)

afdev82 commented 9 years ago

Ok, thanks. I will think about it, if I can I would be proud to contribute ;)

brian-vogogo commented 8 years ago

The issue is quote_table_name("public.car.color") returns "public"."car" and drops the .color.

We have the same issue while using the Apartment gem to switch between public schemas.

afdev82 commented 8 years ago

Thank you @brian-vogogo ;)