Propel2 icon indicating copy to clipboard operation
Propel2 copied to clipboard

ColumnNotFoundException

Open spidfire opened this issue 7 years ago • 12 comments

I sometimes get a really strange error, not sure if it is propel related: But my error is

Propel\Runtime\Map\Exception\ColumnNotFoundException
Cannot fetch ColumnMap for undefined column: USER_?D in table push_to_user.

The question mark is an utf character.

From sentry I get: image as you can see in the params of the pdo adapter the column is named user_id

Maybe the problem is language related? Because this script sometimes changes language using setlocale? but seems strange that the database fieldnames is susceptible for this?

Maybe in the stroupper in ColumnMap::normalizeName ?

spidfire avatar Apr 03 '19 09:04 spidfire

Try to hexdump that column name and post the code that actually uses the TableMap/Query class. I guess you have a hidden utf8 char somewhere.

marcj avatar Apr 03 '19 09:04 marcj

I think thats not the problem because it works most of the time. and I already checked that before

spidfire avatar Apr 03 '19 09:04 spidfire

It's just a guess. There is definitely something weird in your encoding. Try grep 'user_id' . -rin | wc -l vs grep 'user_' . -rin | wc -l. Same count?

marcj avatar Apr 03 '19 09:04 marcj

It's also important to know whether you pass column names like user_id somewhere or use always the prebuild methods like filterByUserId(xy)

marcj avatar Apr 03 '19 09:04 marcj

Ok, Ive ran a test against all the locales in my db Result all went well expect for::

tr_TR => USER_�D
 en_GY => USER_�D
en_LT => USER_�D

test.php

<?php


$locales = explode(",", 'en_US,en_GB,nl_NL,en,nl_BE,de_AT,da_DK,ja_JP,sl_SI,fr_BE,cs_CZ,de_DE,de,en_IN,hr_HR,fr_US,fr_CA,fr_FR,en_UK,it_IT,fr_DZ,ru_UA,lt_LT,de_CH,nl_DE,nl,en_IE,sv,el_GR,fr_CH,en_AU,pt_PT,pl_PL,fr_NC,en_SI,en_CA,en_NL,nl_AL,de_BE,hr_SI,ru_RU,en_MD,es_US,en_DE,fr_SI,da,fr_PF,sk_SK,sv_SE,en_JP,en_CH,es_ES,it_CH,fr,en_DK,hu_HU,es_CO,bg_BG,pt_CH,gsw_CH,en_SA,en_PT,pt_BR,de_IT,pl_DE,hu_DE,de_HU,es_PE,fr_RE,pl,en_RU,ar_EG,fi_NL,mk_MK,nl_US,en_NO,hu_NL,en_LV,en_EE,et_EE,ru_KZ,de_LU,de_NL,en_MY,en_MT,it_MT,en_BE,en_AT,ro_DE,fr_MT,ro_RO,bg_DE,ru_AE,en_CZ,en_FR,fi_FI,de_US,ms_MY,ru_IL,nl_GB,en_BR,de_SI,en_IT,lb_LU,lb_FR,fr_LU,en_LU,en_TR,cy_GB,pl_MT,ko_KR,es_CH,zh_TW,hu,en_RO,nl_NZ,hu_GB,nb_NO,es_BE,ksh_DE,en_DO,fr_NL,ru_TJ,pt_DE,es_419,es_DE,ru_DE,zh_CN_#Han,ru_US,en_NZ,en_SK,fi_MT,tr_TR,en_GY,en_LT,iw_IL,ca_NL,fr_CD,pt_LU,vi_VN,en_CD,gsw_IT,fr_SN,ru_EE,ar_AE,en_SG,fr_MA,gsw_LI,sr_RS,he_IL,de_LT,nl_BQ,en_UA,es_AR,ru_KG,sl_HR,hu_US,en_ES,mt_MT,de_PT,ru_SI,it_GB');

foreach($locales as $l){
	setlocale(LC_ALL, $l);
	$name = 'user_id';
        $r = strtoupper($name);
	echo "$l => $r \n";
}

spidfire avatar Apr 03 '19 10:04 spidfire

Maybe replace by mb_strtoupper($name, 'UTF-8') ? this will negate the setted locales https://www.php.net/manual/en/function.mb-strtoupper.php

spidfire avatar Apr 03 '19 10:04 spidfire

Rectification it's only tr_TR the other ones were just ignored

spidfire avatar Apr 03 '19 11:04 spidfire

Is this going to be fixed in further releases?

spidfire avatar Jun 03 '19 07:06 spidfire

Is someone able to make a PR here with suggested changes? @spidfire

dereuromark avatar Jul 01 '20 13:07 dereuromark

There is a caviat, This could add mb_string dependency to the project, not sure if that is already the case?

spidfire avatar Jul 01 '20 14:07 spidfire

mb_ methods usually are pretty much a given these days with PHP.

dereuromark avatar Jul 01 '20 14:07 dereuromark

That is true and we use it so there is no problem for us. But maybe you want to add it atleast to composer.json and maybe replace other functions also ?

spidfire avatar Jul 01 '20 14:07 spidfire