Ticket #1666 (closed defect: fixed)
Data Export Doesn't export the keys correctly.
| Reported by: | marijn | Owned by: | jwage |
|---|---|---|---|
| Priority: | major | Milestone: | 1.0.6 |
| Component: | Import/Export | Version: | 1.0.3 |
| Severity: | Keywords: | export data fixture | |
| Cc: | Has Test: | no | |
| Status: | Pending Core Response | Has Patch: | no |
Description
Problem set:
I'm using Doctrine in combination with symfony, when exporting data the following errors occur:
$ symfony doctrine:data-dump ApplicationName fixture_file.yml >> Invalid argument supplied for foreach() in plugins/sfDoctrinePlugin/lib/doctrine/Doctrine/Data/Export.php on line 163 >> doctrine Dumped data successfully to: /data/fixtures/fixture_file.yml
I've had a look at that line but the only thing happening there is a toArray(false) call on the Doctrine_Record that is to be exported.
The fixture file that is produced is unusable. If I call a reload procedure it doesn't load the data.
Example:
The error can be regenerated with the following schema:
Asset:
columns:
id: { type: integer, length: 4, primary: true, autoincrement: true }
name: { type: string, length: 255 }
description: { type: string, length: 255 }
mime_type: { type: enum, values: [ image/jpeg, image/png, image/gif ] }
actAs:
Versionable: { versionColumn: version, className: %CLASS%Version, auditLog: true }
Sluggable: { unique: true, fields: [ name ], canUpdate: false }
Timestampable: { created: { name: created_at }, updated: { name: updated_at } }
SoftDelete: { }
ImageAsset:
inheritance:
extends: Asset
type: column_aggregation
keyField: content_type
keyValue: 1
Create the following fixture files, 001_assets.yml:
Asset: { }
002_image_assets.yml:
ImageAsset:
test_image_asset_1:
name: Test Image 1
description: Description Test Image 1
mime_type: image/jpeg
test_image_asset_2:
name: Test Image 2
description: Description Test Image 2
mime_type: image/gif
test_image_asset_3:
name: Test Image 3
description: Description Test Image 3
mime_type: image/png
Rebuild the model:
$ symfony doctrine:build-all-reload ApplicationName
Check if all is loaded correctly:
$ symfony doctrine:dql Test "SELECT a.* FROM Asset a"
Drop the data
$ symfony doctrine:data-dump ApplicationName incorrect_data.yml >> Invalid argument supplied for foreach() in plugins/sfDoctrinePlugin/lib/doctrine/Doctrine/Data/Export.php on line 163 >> doctrine Dumped data successfully to: /data/fixtures/incorrect_data.yml
Try to reload:
$ symfony doctrine:build-all-reload ApplicationName >>`Invalid row key specified: ImageAsset_1`
The error is the result of the incorrect keys in the generated fixtures file.
Environment:
- Symfony 1.1.4
- sfDoctrinePlugin
- Doctrine 1.0.3 *PHP 5.2.4
Attachments
Change History
Note: See
TracTickets for help on using
tickets.