GithubHelp home page GithubHelp logo

Comments (5)

pcreux avatar pcreux commented on September 2, 2024 1

Hey @stevenou , I'm glad that this gem is saving you some time!

Thank you for reporting this. I believe that it's coming from:

model.errors.map do |attribute, errors|

I'm wondering if this API (errors.each do |error|) is compatible with Rails 4+ or if there's something like errors.to_h.

PRs are welcomed. ;)

from csv-importer.

stevenou avatar stevenou commented on September 2, 2024

Ok, so it would appear that csv-importer currently actually only returns the last error for each attribute, not all errors for each attribute. That's because the Hash[] here will only retain the last error if there are multiple entries with the same key (column_name/attribute)

Hash[
model.errors.map do |attribute, errors|
if column_name = header.column_name_for_model_attribute(attribute)
[column_name, errors]
else
[attribute, errors]
end
end
]

Ideally, we might want to change the value in the resulting hash to be an array, rather a string, so it can hold all errors for a given attribute. However, that is probably a breaking change.

So I'll just submit a PR to remove the deprecation warning but keep the existing behavior. We can discuss the breaking change separately.

from csv-importer.

pcreux avatar pcreux commented on September 2, 2024

You're 100% right. I'm not convinced that only keeping the last error was intentional. Let's merge your PR in for the 0.8.1 version. I believe that we could then release 0.9.0 where errors would return a hash where values would be array of errors.

from csv-importer.

stevenou avatar stevenou commented on September 2, 2024

May I suggest making that 1.0.0 as that would be a breaking change?

from csv-importer.

pcreux avatar pcreux commented on September 2, 2024

@stevenou Yes, that makes sense. It always feels like a big jump to release 1.0.0 but it's the right call. I'm going to look at removing the dependency to virtus since it's not maintained anymore.

from csv-importer.

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.