Ticket #2819 (closed bug: fixed)

Opened 3 years ago

Last modified 3 years ago

Copied record field mismatch from shapefile to postgis

Reported by: bonzai Owned by: jef
Priority: minor: annoyance Milestone: Version 1.5.0
Component: Data Provider Version: 1.4.0
Keywords: Cc:
Platform Version: Platform: Gentoo
Must Fix for Release: No Awaiting user input: yes

Description

During feature copy (using Ctrl+C Ctrl+V) between shapefile and postgis layers field's values are someway shifted.

Original SHAPEFILE feature attributes
app_id: NULL
su_id: NULL
su: 36 <-------- RIGHT
phase: NULL
date: NULL

Copied PostGIS feature attributes
app_id: NULL
su_id: 36 <--------- WRONG
su: NULL
phase: NULL
date: NULL

Change History

follow-up: ↓ 2   Changed 3 years ago by jef

  • status_info set

The field values are assigned in order not by name. Does the attribute order in your postgis table match the order of fields in the shapefile's dbf?

in reply to: ↑ 1   Changed 3 years ago by bonzai

Replying to jef:

The field values are assigned in order not by name. Does the attribute order in your postgis table match the order of fields in the shapefile's dbf?

Looking in layers' properties attribute tab I've found this:

SHAPEFILE
-|id|name
1|0 |app_id
2|1 |su_id
3|2 |su <-------
4|3 |phase
5|4 |date

POSTGIS
-|id|name
1|0 |app_id
2|2 |su_id
3|3 |su <-------
4|4 |phase
5|5 |date

So it seems thats records have the same order but different ids. A further information that could you help: the shapefile is the result of 'Export as shapefile' QGIS command.

follow-ups: ↓ 4 ↓ 5   Changed 3 years ago by jef

Might the geometry column in postgis not be the last column?

in reply to: ↑ 3   Changed 3 years ago by bonzai

Replying to jef:

Might the geometry column in postgis not be the last column?

Actually it's not a table but a view with insert,update,delete rules:

CREATE OR REPLACE VIEW dataschemaname.w_core_geom_sus AS

SELECT g.app_id, g.geom, s.app_id AS su_id, s.short_def AS su, ph.short_def AS phase, s.date

FROM dataschemaname.core_geom_sus g LEFT JOIN dataschemaname.core_std_sus s ON g.su_id = s.app_id LEFT JOIN dataschemaname.core_voc_phases ph ON s.phase_id = ph.app_id;

As you can see the geometry column is the second one. Should it be the last one? It's not a big issue but I've never heard about this...

in reply to: ↑ 3 ; follow-up: ↓ 6   Changed 3 years ago by bonzai

  • priority changed from major: does not work as expected to minor: annoyance

Replying to jef:

Might the geometry column in postgis not be the last column?

Reoerdering view's fields putting geometry colums last works for me. But in my opinion it's just a workaround and not a proper solution so I just changed the priority to minor.

Thanks for the quick answer

in reply to: ↑ 5   Changed 3 years ago by jef

  • owner changed from nobody to jef

Replying to bonzai:

Reoerdering view's fields putting geometry colums last works for me. But in my opinion it's just a workaround and not a proper solution so I just changed the priority to minor.

Sure it is.

  Changed 3 years ago by jef

  • status changed from new to closed
  • resolution set to fixed

fixed in r13808.

Note: See TracTickets for help on using tickets.