Default import ignores item id's if ID does not exist #601

Closed
opened 2020-09-18 05:25:55 +00:00 by marcorensch · 3 comments
marcorensch commented 2020-09-18 05:25:55 +00:00 (Migrated from github.com)

Steps to reproduce the issue

  1. Create some items to export in a JCB compiled component.

  2. Delete some items, create additional ones so that the ID's are no longer consecutive. (the ID's would be e.g. 1,3,6,7,8).

  3. Perform an export

  4. Delete the contents of the table completely from the database or switch to another installation

  5. Perform an import and map the ID column in the database to the ID column in Excel (1,3,6,7,8)

Expected result

The items are imported into the database with their ID's, because I set the option during import (the mapping) accordingly. If I don't want the ID's to be taken over I can ignore this column during import or remove it in Excel before...

Actual result

The items will be written to the database with new ID's (9,10,11,12,13 or 1,2,3,4,5 on a blank install) - components that link from one item to another will be unusable / the import / export will be useless.

Workaround

I have to import via PHPMyAdmin to import the ID's

Could be reproduced locally and on the live system.

System information (as much as possible)

  • OS Name & Version: MacOS
  • MySql Version:
  • Apache Version:
  • PHP Version: 7.4.2
  • Joomla Version: 3.9.21
  • JCB Version: 2.11.4
  • Browser: Firefox

Additional comments

My components does a link between items - Teams are linked to employees, teams are linked to locations. For the selection I use the ID of the element so that the column "assigned_team" in the table "Employees" contains the ID of the corresponding team of the table "Teams".

The other Import Scenarios (incl. update when id exists) works fine

### Steps to reproduce the issue 1. Create some items to export in a JCB compiled component. 2. Delete some items, create additional ones so that the ID's are no longer consecutive. (the ID's would be e.g. 1,3,6,7,8). 3. Perform an export 4. Delete the contents of the table completely from the database or switch to another installation 5. Perform an import and map the ID column in the database to the ID column in Excel (1,3,6,7,8) ### Expected result The items are imported into the database with their ID's, because I set the option during import (the mapping) accordingly. If I don't want the ID's to be taken over I can ignore this column during import or remove it in Excel before... ### Actual result The items will be written to the database with new ID's (9,10,11,12,13 or 1,2,3,4,5 on a blank install) - components that link from one item to another will be unusable / the import / export will be useless. ### Workaround I have to import via PHPMyAdmin to import the ID's Could be reproduced locally and on the live system. ### System information (as much as possible) - OS Name & Version: MacOS - MySql Version: - Apache Version: - PHP Version: 7.4.2 - Joomla Version: 3.9.21 - JCB Version: 2.11.4 - Browser: Firefox ### Additional comments My components does a link between items - Teams are linked to employees, teams are linked to locations. For the selection I use the ID of the element so that the column "assigned_team" in the table "Employees" contains the ID of the corresponding team of the table "Teams". The other Import Scenarios (incl. update when id exists) works fine
duetnet commented 2020-09-18 18:35:39 +00:00 (Migrated from github.com)

Hi MarcoI understand your issue. Although many joomla components seem to base the key of a table on ID, I date myself as an old 3rd generation  programmer where this ID is nothing more than the record number. Linking tables relations on record number is not a good idea.All my tables have unique key fields on which I base my relationships between tables.For example employee number or account number or event number.This means when I export and import data the ID is not relevantFranzSent from my Samsung device

-------- Original message --------
From: Marco notifications@github.com
Date: 2020/09/18 07:26 (GMT+02:00)
To: vdm-io/Joomla-Component-Builder Joomla-Component-Builder@noreply.github.com
Cc: Subscribed subscribed@noreply.github.com
Subject: [vdm-io/Joomla-Component-Builder] Default import ignores item id's
  (#601)

Steps to reproduce the issue

Create some items to export in a JCB compiled component.

Delete some items, create additional ones so that the ID's are no longer consecutive. (the ID's would be e.g. 1,3,6,7,8).

Perform an export

Delete the contents of the table completely from the database or switch to another installation

Perform an import and map the ID column in the database to the ID column in Excel (1,3,6,7,8)

Expected result
The items are imported into the database with their ID's, because I set the option during import (the mapping) accordingly. If I don't want the ID's to be taken over I can ignore this column during import or remove it in Excel before...
Actual result
The items will be written to the database with new ID's (9,10,11,12,13 or 1,2,3,4,5 on a blank install) - components that link from one item to another will be unusable / the import / export will be useless.
Workaround
I have to import via PHPMyAdmin to import the ID's
Could be reproduced locally and on the live system.
System information (as much as possible)

OS Name & Version: MacOS
MySql Version: idk
Apache Version:
PHP Version:
Joomla Version:
JCB Version:
Browser:

Additional comments
My components does a link between items - Teams are linked to employees, teams are linked to locations. For the selection I use the ID of the element so that the column "assigned_team" in the table "Employees" contains the ID of the corresponding team of the table "Teams".

—You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe.
[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/vdm-io/Joomla-Component-Builder/issues/601",
"url": "https://github.com/vdm-io/Joomla-Component-Builder/issues/601",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
}
]

Hi MarcoI understand your issue. Although many joomla components seem to base the key of a table on ID, I date myself as an old 3rd generation  programmer where this ID is nothing more than the record number. Linking tables relations on record number is not a good idea.All my tables have unique key fields on which I base my relationships between tables.For example employee number or account number or event number.This means when I export and import data the ID is not relevantFranzSent from my Samsung device -------- Original message -------- From: Marco <notifications@github.com> Date: 2020/09/18 07:26 (GMT+02:00) To: vdm-io/Joomla-Component-Builder <Joomla-Component-Builder@noreply.github.com> Cc: Subscribed <subscribed@noreply.github.com> Subject: [vdm-io/Joomla-Component-Builder] Default import ignores item id's &nbsp; (#601) Steps to reproduce the issue Create some items to export in a JCB compiled component. Delete some items, create additional ones so that the ID's are no longer consecutive. (the ID's would be e.g. 1,3,6,7,8). Perform an export Delete the contents of the table completely from the database or switch to another installation Perform an import and map the ID column in the database to the ID column in Excel (1,3,6,7,8) Expected result The items are imported into the database with their ID's, because I set the option during import (the mapping) accordingly. If I don't want the ID's to be taken over I can ignore this column during import or remove it in Excel before... Actual result The items will be written to the database with new ID's (9,10,11,12,13 or 1,2,3,4,5 on a blank install) - components that link from one item to another will be unusable / the import / export will be useless. Workaround I have to import via PHPMyAdmin to import the ID's Could be reproduced locally and on the live system. System information (as much as possible) OS Name & Version: MacOS MySql Version: idk Apache Version: PHP Version: Joomla Version: JCB Version: Browser: Additional comments My components does a link between items - Teams are linked to employees, teams are linked to locations. For the selection I use the ID of the element so that the column "assigned_team" in the table "Employees" contains the ID of the corresponding team of the table "Teams". —You are receiving this because you are subscribed to this thread.Reply to this email directly, view it on GitHub, or unsubscribe. [ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/vdm-io/Joomla-Component-Builder/issues/601", "url": "https://github.com/vdm-io/Joomla-Component-Builder/issues/601", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } } ]
marcorensch commented 2020-09-18 18:53:04 +00:00 (Migrated from github.com)

Hi Franz, I understand your point of view and yes, probably I will be forced to structure my component in a similar way - I am currently checking if I can edit the import manually with custom code so that the desired behaviour (ID is always written to the database during import) is fulfilled. I must emphasize that due to the requirements and the GUI it is implied that this is already the case when I link the ID to the table column during import...

Hi Franz, I understand your point of view and yes, probably I will be forced to structure my component in a similar way - I am currently checking if I can edit the import manually with custom code so that the desired behaviour (ID is always written to the database during import) is fulfilled. I must emphasize that due to the requirements and the GUI it is implied that this is already the case when I link the ID to the table column during import...
marcorensch commented 2020-09-23 09:42:17 +00:00 (Migrated from github.com)

Closed because can be solved when using custom import and change / remove
// remove id if ('id' == $target[$key]) { continue; }
around row 116 in custom import script's save function

Closed because can be solved when using custom import and change / remove `// remove id if ('id' == $target[$key]) { continue; }` around row 116 in custom import script's save function
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: joomla/Component-Builder#601
No description provided.