umpirsky / country-list

:globe_with_meridians: List of all countries with names and ISO 3166-1 codes in all languages and data formats.
MIT License
5.16k stars 1.55k forks source link

Update country.postgresql.sql #30

Open cangcool opened 10 years ago

cangcool commented 10 years ago

When I imported this file on pgAdmin III, I've got error on line 185, because of "\'". Maybe its better to remove it After removed it, I imported it successfully. Many thanks

rostenkowski commented 10 years ago

You have changed the name of the country! And what more, you have done it only in PostgreSQL format!

The correct solution is to escape that apostrophe using proper method. Escaping character \ is wrong becuase in PostgreSQL it is done trough the double apostrophe '' as explained eg. here: http://stackoverflow.com/a/12320729

umpirsky commented 10 years ago

You changed the data, and you changed it only for en language.

I guess it should be escaped here and then rebuilt.

jlbooker commented 9 years ago

I've just run across this bug as well. The current SQL does not run to completion because of the quotation issue with 'People\'s Democratic Republic of Yemen'. It should be 'People''s Democratic Republic of Yemen' (notice the two single quotes), as per http://www.postgresql.org/docs/8.2/static/sql-syntax-lexical.html (section 4.1.2.1).

It seems that adding these quotes is the responsiblity of the Zend framework you're using, specifically the Platform object in the call: ->getSqlString($this->getPlatform()). The Platform object is supposed to supply the platform-dependent quoting style. The Zend framework seems to be using an old style (\') which newer version of Postgresql don't support. The offending line seems to be here:

https://github.com/zendframework/zf2/blob/master/library/Zend/Db/Adapter/Platform/Postgresql.php#L101

umpirsky commented 9 years ago

@jlbooker Thanks for your input. Then we should report it to zf https://github.com/zendframework/zf2/issues/new.

jlbooker commented 9 years ago

@umpirsky Yes, definitely sounds like it should be reported to ZendFramework. I don't have the Zend Framework installed anywhere though, so I can't rebuild, test, nor reproduce the problem with the latest version of ZF. I'll leave it for you to report if you'd like.