{"action":"created","issue":{"url":"https://api.github.com/repos/bcosca/fatfree-core/issues/106","labels_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/106/labels{/name}","comments_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/106/comments","events_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/106/events","html_url":"https://github.com/bcosca/fatfree-core/issues/106","id":122926769,"number":106,"title":"PDO string conversion of floating values not reliable","user":{"login":"xfra35","id":1838531,"avatar_url":"https://avatars.githubusercontent.com/u/1838531?v=3","gravatar_id":"","url":"https://api.github.com/users/xfra35","html_url":"https://github.com/xfra35","followers_url":"https://api.github.com/users/xfra35/followers","following_url":"https://api.github.com/users/xfra35/following{/other_user}","gists_url":"https://api.github.com/users/xfra35/gists{/gist_id}","starred_url":"https://api.github.com/users/xfra35/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xfra35/subscriptions","organizations_url":"https://api.github.com/users/xfra35/orgs","repos_url":"https://api.github.com/users/xfra35/repos","events_url":"https://api.github.com/users/xfra35/events{/privacy}","received_events_url":"https://api.github.com/users/xfra35/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-12-18T10:54:12Z","updated_at":"2015-12-21T13:51:08Z","closed_at":null,"body":"Since PDO doesn't handle floating points, the framework has to [cast](https://github.com/bcosca/fatfree-core/blob/c9681ed5b2b5ec34abca1afd9be275d469aa24ec/db/sql.php#L116) float values to string.\r\n\r\nThis work well with locales having `.` as a decimal separator, but not for those having `,`:\r\n```php\r\n$f3->LANGUAGE='fr';\r\n$price=12.34;\r\n$mapper->set('price',$price);\r\nvar_dump($mapper->price);// '12,34' <= there shouldn't be a comma here\r\n$mapper->save();// <= value stored in database = 12\r\n```\r\nThe only way to have this working is to perform a custom string cast before each call to `set` or to overload the `set()` method:\r\n```php\r\n$mapper->set('price',str_replace(',','.',$price));\r\nvar_dump($mapper->price);// '12.34' <= OK\r\n```\r\nThis is not convenient and can lead to mistakes.\r\n\r\nI think that the framework should handle it, but I'm not sure how. Maybe by adding a `float` flag in the `$db->schema` result?\r\n\r\nAny idea?"},"comment":{"url":"https://api.github.com/repos/bcosca/fatfree-core/issues/comments/166309889","html_url":"https://github.com/bcosca/fatfree-core/issues/106#issuecomment-166309889","issue_url":"https://api.github.com/repos/bcosca/fatfree-core/issues/106","id":166309889,"user":{"login":"xfra35","id":1838531,"avatar_url":"https://avatars.githubusercontent.com/u/1838531?v=3","gravatar_id":"","url":"https://api.github.com/users/xfra35","html_url":"https://github.com/xfra35","followers_url":"https://api.github.com/users/xfra35/followers","following_url":"https://api.github.com/users/xfra35/following{/other_user}","gists_url":"https://api.github.com/users/xfra35/gists{/gist_id}","starred_url":"https://api.github.com/users/xfra35/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xfra35/subscriptions","organizations_url":"https://api.github.com/users/xfra35/orgs","repos_url":"https://api.github.com/users/xfra35/repos","events_url":"https://api.github.com/users/xfra35/events{/privacy}","received_events_url":"https://api.github.com/users/xfra35/received_events","type":"User","site_admin":false},"created_at":"2015-12-21T13:51:08Z","updated_at":"2015-12-21T13:51:08Z","body":"@geniuswebtools is right, the value gets truncated because MySQL expects a dot as a separator, not a comma. I haven't tried yet with other SQL engines.\r\n\r\n> Is that due to your fr language setting?\r\n\r\nYes, and I expect the same behaviour with `de`. Haven't you face the problem already?"}}