leikind / wice_grid

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

Time to return upstream? #394

Closed afdev82 closed 1 month ago

afdev82 commented 1 month ago

Hello,

I see that this repo got some new commits this year after a long time. On the other side, the repo that was suggested in the README as a successor seems to be not actively maintained anymore. Is it time now to return to the original repo? Does anyone know what's going on?

I see that the commits are taken from that repo until 39e301c349bff5db271dec3222c5ca91d4bfcbd4, but I was also using this branch to get some fixes, do you mind if I will help merging that too? I think there are commits there and here to fix the same issues, it would be needed some work to merge. I have also submitted a PR to fix a bug, would you mind to accept a PR also here?

It would be nice to have a clear reference for this project and restarting from here it looks promising. Thank you for your support.

dima4p commented 1 month ago

Hello @afdev82, yes, it is the time to return to the upstream. The default branch has the hame "rails7". That means it works with the RoR 7.0 and higher. The brunch rails6 works with RoR 6. I have never checked, but the default brunch should work with RoR 6 too. Regarding the column that has "-" in the name I can say that the table with such a name was not created with rails. Rails always uses underscores in column names. If you have such a table, simple rename these columns replacing minus to underscore. Wbr, Dimitri

afdev82 commented 1 month ago

Hello @dima4p, yeah, for my specific issue it is not that easy... I have my complete application based on these format for the name of some columns, there is a logic behind why I need the "-" and I use also the "_" inside the same name. In Rails, the character is valid for a column name, so I think it should be supported. I think it's not a big change to do. Regarding the other questions, I assume no help is needed.

dima4p commented 1 month ago

Hello @afdev82, no, if you want to have a '-' in the column name, for example, display-id, you'll have to write in your code model.display-id to access the value that will be interpreted as model.display - id and lead to an error. I can suggest you to use double underscore to represent the meaning you use for '-'.

afdev82 commented 1 month ago

Yes,

you have to use the quotes in the queries, like I did in this PR to fix the problem. In Rails you can just use model['display-id'], I am using this way for years now and I had no problems at all. That said, if you don't want to change the code, it's also OK for me. For my needs I could use a fork (like now).

Currently I have another issue using Rails bigger than 7.0, I am debugging the problem and eventually I will open another issue for that. I am trying to understand if it is with Rails 7.1 or 7.2.

dima4p commented 1 month ago

you have to use the quotes in the queries, like I did in this PR to fix the problem. In Rails you can just use model['display-id'], I am using this way for years now and I had no problems at all. That said, if you don't want to change the code, it's also OK for me. For my needs I could use a fork (like now).

Yes, this is a solution. But it is not a "Rails way".

Currently I have another issue using Rails bigger than 7.0, I am debugging the problem and eventually I will open another issue for that. I am trying to understand if it is with Rails 7.1 or 7.2.

Do you use the brunch rails7?

afdev82 commented 1 month ago

Yes, this is a solution. But it is not a "Rails way".

I think it's more a matter of taste about code styling... There are feature in Postgresql (e.g. querying jsonb columns) that require strings in ActiveRecord queries. The "-" character is a valid character for object key names also in Javascript and also there I have to access them using the brackets and not with the ".".

Do you use the brunch rails7?

Yes, I have tried with the original branch and a branch with that change for my needs. In both cases the error I had is gone. When I have tried to filter the data on the ID column (integer), I had the following error:

PG::InvalidTextRepresentation: ERROR: invalid input syntax for type integer: "65578.0"

But now that the error is gone, the results are not filtered for that column. I see all rows and not only one.

afdev82 commented 1 month ago

I have tested a bit with the different Rails versions. With Rails 7.1.4.1 and my old branch the filter works. With Rails 7.2.1.1 and my old branch it doesn't work, it doesn't matter if I use the defaults of Rails 7.1 in application.rb or not, so it should be something in the framework itself. With Rails 7.2.1.1 or Rails 7.1.4.1 and the rails7 branch, the filter doesn't work, but I don't get any error. I get all the records unfiltered. I will try to understand what's going on and report in another issue if I find something. Thank you for the given support until now.

dima4p commented 1 month ago

I have tested a bit with the different Rails versions. With Rails 7.1.4.1 and my old branch the filter works. With Rails 7.2.1.1 and my old branch it doesn't work, it doesn't matter if I use the defaults of Rails 7.1 in application.rb or not, so it should be something in the framework itself. With Rails 7.2.1.1 or Rails 7.1.4.1 and the rails7 branch, the filter doesn't work, but I don't get any error. I get all the records unfiltered. I will try to understand what's going on and report in another issue if I find something. Thank you for the given support until now.

Du you use the gem version 7.1.2?

afdev82 commented 1 month ago

I was using the v7.1.1. Now I have tested also the v7.1.2. With Rails 7.1.4.1 it works. With Rails 7.2.1.1 it doesn't work, I get now the same error I have got already with my old branch.

afdev82 commented 1 month ago

I don't find the source code for the v7.1.2, so I can't have a look to what changed.

dima4p commented 1 month ago

I don't find the source code for the v7.1.2, so I can't have a look to what changed.

Sorry, I forgot to push it. Now it is there.

afdev82 commented 1 month ago

I will open another issue for this bug with Rails 7.2 when I will return to work on that. For the moment I am using the old branch with Rails 7.1.