This should be fairly easy.

The highlight to keep in mind

What when a import want to import an already existing serial number.
--> error dont import that line
This gives the possibility to non sequential serial numbers.
--> is no problem i think, if you now create 5 nodes and delete the 3th and 4th you also has non sequential serial field values.

The important part is that after the import there needs to be a check to test if the highest imported value for the serial field is still lower than the current auto_increment field in the database.
-->If not update the auto_increment to the highest imported serial field

Our use case:
We have a new system using drupal and use serial field extensively. We need to import data from the old system and are using feeds.
There are a lot of enity references involved, a lot of content-types, a lot with 1 or more serial fields.
We know of our import that every serial field is unique

Comments

manuelBS’s picture

Did you already solve this issue?

Parkes Design’s picture

+ 1 has any one come up with a solution for this yet?

ikeigenwijs’s picture

We used a workaround.

We added dummy entries for the missing serial fields and removed them after the import.
The imported rows in the files then correlated with the serial field value that was created.

This was possible to the small number of gabs.
For other entries we just reassigned the new numbers we where in a move/reorganization anyway so it was a small extra effort.

I still think the feature would be valuable.

eric_a’s picture

Status: Active » Needs review
StatusFileSize
new1.48 KB

Here's a start.

eric_a’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
eric_a’s picture

Assigned: Unassigned » eric_a
Status: Needs review » Needs work

Just found out that ID tracking/reserving is broken when importing items with feeds. I'll provide a fix in this issue later.

eric_a’s picture

Status: Needs work » Needs review
StatusFileSize
new1.37 KB
new2.84 KB

Here we go. This fixes ID tracking for imported values, so that manually created nodes cannot re-use those values. There's no further logic, a feeds importer can do whatever it wants, wether the value existed or not.

yazzbe’s picture

#7 seems to work fine.

patched against 7.x-1.8

eric_a’s picture

Status: Needs review » Needs work

Well, to be honest, "optional_unique" and "unique_callbacks" do need to be implemented.

skylord’s picture

Status: Needs work » Needs review
StatusFileSize
new3.44 KB

Actually, default "unique_callbacks" implementation from Feeds API example can be used. Works OK for me on feed with about 20k entries (11 was with duplicated serial field successfully updated using it).

FireHawkX’s picture

Status: Needs review » Reviewed & tested by the community

Tested patch #10 and it worked perfectly. Was able to import thousands of numbers in the serial field, and when it was all imported, serial started after the latest number added!