partkeepr / PartKeepr

Open Source Inventory Management
http://www.partkeepr.org
GNU General Public License v3.0
1.38k stars 400 forks source link

Storage Location importer from CSV does nothing when "Execute Import" #869

Closed andreaslink-de closed 4 years ago

andreaslink-de commented 7 years ago

I have an issue, when trying so setup my storage locations in a fresh install. I've created a CSV file which I'd like to import into the inventory using the import tool. CSV file is accepted and also preview looks promising, but when I press "Execute Import" simply nothing happens. Even no errors are shown.

I have created a categorie and a subcategorie (see screenshot) and then I just want to create some simple storage locations below. It might that I'm using the tool wrong or relevant datalis are not setup, but I was not able to find a description on how to use the importer correctly. So I tried best on my own.

System Information

Screenshots: partkeepr_storagelocations_import-issue_2017-06-03

partkeepr_systeminformation_2017-06-03

Files: Drehturm-Numbering.csv.zip Remind: "Ergebnis" as seen in screenshot is finally named "Name-Lagerort" in the attached CSV-File I finally used. Sorry for slight difference between screenshot and test-file, bit this has no effect on the issue.

How to reproduce

I'm very much looking for a how-to-do-this-import-best, because I guess, this is not a bug in the tool, but a failure in how to use it correctly. Probably I need to set some categorie values and is it sufficient to select the correct subfolder or do I have to enter further information? Is "name" the correct column?

Drachenkaetzchen commented 7 years ago

Can you check if there's an error in app/logs/partkeepr.log or in the other log files? The problem should be logged

andreaslink-de commented 7 years ago

Thanks for the fast feedback, I wasn't aware of these logfiles, as I did find anything in the apache.log or syslog. But what I find in there are many entries like these:

[2017-06-03 22:08:45] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'INSERT INTO StorageLocation (name, category_id) VALUES (?, ?)' with params ["Turm E-1-1", null]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-1-1' for key 'UNIQ_2C59071C5E237E06'" at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 66 {"exception":"[object] (Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException(code: 0): An exception occurred while executing 'INSERT INTO StorageLocation (name, category_id) VALUES (?, ?)' with params [\"Turm E-1-1\", null]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-1-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:66, Doctrine\\DBAL\\Driver\\PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-1-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-1-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} []

So I was searching for "Turm E-1-1" and I found a slight error in my CSV file, where I harm this rule. I fixed it, and then I get a pop-up showing something I cannot scroll (closed it before screenshot). So I move forward now, but it would have been great, if I would have gotton this key-issue from the frontend :-).

But anyway, I cannot find these new storage locations now? They seem to be imported into the nowhere. What do I have to define exactly, to have a successful import of locations into a dedicated subcategory? Is only the name sufficient? How does the importer know the categorie?

When I try to reimport I will now get the following errror: [2017-06-03 22:55:00] request.CRITICAL: Uncaught PHP Exception Doctrine\DBAL\Exception\UniqueConstraintViolationException: "An exception occurred while executing 'INSERT INTO StorageLocation (name, category_id) VALUES (?, ?)' with params ["Turm E-7-1", null]: SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-7-1' for key 'UNIQ_2C59071C5E237E06'" at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php line 66 {"exception":"[object] (Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException(code: 0): An exception occurred while executing 'INSERT INTO StorageLocation (name, category_id) VALUES (?, ?)' with params [\"Turm E-7-1\", null]:\n\nSQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-7-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php:66, Doctrine\\DBAL\\Driver\\PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-7-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:93, PDOException(code: 23000): SQLSTATE[23000]: Integrity constraint violation: 1062 Duplicate entry 'Turm E-7-1' for key 'UNIQ_2C59071C5E237E06' at /var/www/partkeepr/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOStatement.php:91)"} []

This seems to proove, my former import was successfull, but somehow into the nowhere and I have the impression, I've fucked up my storage locations now :-). Any ideas, where to find my storage locations?

Drachenkaetzchen commented 7 years ago

Hmm I believe you are struck by a bug in 1.2.0 where you have to create the storage locations first. The storage locations can be found in Edit->Storage Locations. The reason for the storage location issue that it tries to create multiple storage locations with the same name, which fails. This should be fixed in GIT and on the demo site

andreaslink-de commented 7 years ago

What do you mean with "have to create the storage locations first.", this is what I'm trying to do with this import? As there only had been around 20 manually (by me) created locations, I decided to import the rest of them by using the CSV import. This is my preparation before entering all my parts. So I first created two categories, then I added some test-locations and finally I was trying to import the rest of them via importer. According to my interpretation of the log, I guess, my former failure was to forget to set a category, they were all imported as with params ["Turm E-7-1", null]: but they should have been imported like this with params [\"Turm E-7-1\", \"7\"] as I do INSERT INTO StorageLocation (name, category_id) [...]. So a category should always be mandatory or it should refer to root, but "null" should never be allowed :-S. Now I have quite some entries in my table, but without a category and now I also think, this might probably be a bug :-), something in the code/importer should prevent this. Can I fix this issue via SQL by just updating the records to my (sub)category with ID 7?

Drachenkaetzchen commented 7 years ago

What do you mean with "have to create the storage locations first.", this is what I'm trying to do with this import? As there only had been around 20 manually (by me) created locations, I decided to import the rest of them by using the CSV import.

I'm sorry, I didn't read the bug report properly.

According to my interpretation of the log, I guess, my former failure was to forget to set a category, they were all imported as with params ["Turm E-7-1", null]: but they should have been imported like this with params [\"Turm E-7-1\", \"7\"] as I do INSERT INTO StorageLocation (name, category_id) [...]. So a category should always be mandatory or it should refer to root, but "null" should never be allowed :-S.

That's true. This needs to be fixed. As the importer is very generic in its implementation, there might be an issue where some mandatory fields or associations are not properly reflected yet. Thanks for spotting the issue!

Now I have quite some entries in my table, but without a category and now I also think, this might probably be a bug :-), something in the code/importer should prevent this. Can I fix this issue via SQL by just updating the records to my (sub)category with ID 7?

Yes, that should be possible without a problem.

Drachenkaetzchen commented 7 years ago

By the way, there's a feature which allows you to create multiple storage locations at once if you number them sequentially: https://twitter.com/PartKeepr/status/869141128070782977

andreaslink-de commented 7 years ago

Thanks for the feedback, and no problem for not reading properly, because this exchange finally solved my issue :+1: . I checked via SQL and I could easily identify the records: partkeepr_storagelocations_sql_2017-06-03

Then I simply fired: UPDATE StorageLocation SET category_id=7 WHERE category_id IS NULL which fixed all my NULL entries and now I can see them all as if they had been imported. So my personal issue has been fixed now, but never the less it could be worth to "somehow" mark relevant fields on one hand and on the other hand also ensure, if there are primary key violations, to return them to the frontend.

Regarding the multiple storage creations tool, this is a good thing, but not flexible enough, as I have a rack with e.g. 12 rows and each is having 5 boxes aka storage locations, so a simple counter would not be sufficient in that case as I need "SomeFixedString [Letter]-[Count to 12 as X]-[For each X count from 1 to 5]"

Drachenkaetzchen commented 7 years ago

So my personal issue has been fixed now, but never the less it could be worth to "somehow" mark relevant fields on one hand and on the other hand also ensure, if there are primary key violations, to return them to the frontend.

Yes, both issues must be fixed. Especially the lack of feedback to the user is problematic.

christianlupus commented 4 years ago

I am closing as the main problem has been resolved.