{"action":"created","issue":{"url":"https://api.github.com/repos/laravel/framework/issues/19391","repository_url":"https://api.github.com/repos/laravel/framework","labels_url":"https://api.github.com/repos/laravel/framework/issues/19391/labels{/name}","comments_url":"https://api.github.com/repos/laravel/framework/issues/19391/comments","events_url":"https://api.github.com/repos/laravel/framework/issues/19391/events","html_url":"https://github.com/laravel/framework/issues/19391","id":232000277,"node_id":"MDU6SXNzdWUyMzIwMDAyNzc=","number":19391,"title":"Working with assertDatabaseHas on Sqlite db failing at random asserts","user":{"login":"webmake","id":5016464,"node_id":"MDQ6VXNlcjUwMTY0NjQ=","avatar_url":"https://avatars3.githubusercontent.com/u/5016464?v=4","gravatar_id":"","url":"https://api.github.com/users/webmake","html_url":"https://github.com/webmake","followers_url":"https://api.github.com/users/webmake/followers","following_url":"https://api.github.com/users/webmake/following{/other_user}","gists_url":"https://api.github.com/users/webmake/gists{/gist_id}","starred_url":"https://api.github.com/users/webmake/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/webmake/subscriptions","organizations_url":"https://api.github.com/users/webmake/orgs","repos_url":"https://api.github.com/users/webmake/repos","events_url":"https://api.github.com/users/webmake/events{/privacy}","received_events_url":"https://api.github.com/users/webmake/received_events","type":"User","site_admin":false},"labels":[{"id":572917279,"node_id":"MDU6TGFiZWw1NzI5MTcyNzk=","url":"https://api.github.com/repos/laravel/framework/labels/Under%20Discussion","name":"Under Discussion","color":"fbca04","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2017-05-29T11:42:58Z","updated_at":"2018-09-05T12:05:15Z","closed_at":"2017-06-12T20:43:55Z","author_association":"CONTRIBUTOR","body":"- Laravel Version: 5.4\r\n- Database Driver & Version:\r\nsqlite 3.8.2\r\n\r\n### Description:\r\nWorking with floats (no matter float, double, decimal in schema) and asserting that values exists, there is uncomfortable to work with `assertDatabaseHas` method, because it doesn't find some magic numbers, and fails at random, even value actually exists.\r\nI have some those **magic numbers**, but seems no one still hadn't such situation, it might be sqlite bug, but I suggest to change operator `=` to `like`.\r\n\r\n### Steps To Reproduce:\r\nschema:\r\n```\r\n        Schema::create('some', function(Blueprint $table) {\r\n            $table->increments('id');\r\n            $table->double('commission', 11, 3);\r\n            $table->timestamps();\r\n        });\r\n```\r\nphpunit test:\r\n```\r\n        factory(Some::class)->create([\r\n            'commission' => 2,\r\n        ]);\r\n        \\DB::update('update some set commission = `commission` + ' . 0.28);\r\n        $this->assertDatabaseHas('some', [\r\n            'commission' => 2.28,\r\n        ]);\r\n```\r\ngives:\r\n```\r\nFailed asserting that a row in the table [some] matches the attributes {\r\n    \"commission\": \"2.28\"\r\n}.\r\n\r\nFound: [\r\n    {\r\n        \"id\": \"1\",\r\n        \"commission\": \"2.28\",\r\n        \"created_at\": \"2017-05-29 11:11:38\",\r\n        \"updated_at\": \"2017-05-29 11:11:38\"\r\n    }\r\n].\r\n```\r\n\r\nSimplified model in sqlite, to see whats happening:\r\n```\r\ncreate table \"some\" (\r\n\"id\" integer not null primary key autoincrement,\r\n\"commission\" float not null,\r\n\"created_at\" datetime null,\r\n\"updated_at\" datetime null\r\n);\r\ninsert into \"some\" (\"commission\", \"updated_at\", \"created_at\") values (2, '2017-05-29 11:15:32', '2017-05-29 11:15:32');\r\nupdate some set commission = `commission` + 0.28;\r\n```\r\nSo executed test assert looks like:\r\n```\r\nsqlite> select count(*) as aggregate from \"some\" where (\"commission\" = 2.28);\r\n0\r\n```\r\nSuggestion to change `=` sign to `like`, **if there is possibility**, like SQLiteGrammar does. Then result would be:\r\n```\r\nsqlite> select count(*) as aggregate from \"some\" where (\"commission\" like 2.28);\r\n1\r\n```"},"comment":{"url":"https://api.github.com/repos/laravel/framework/issues/comments/418705976","html_url":"https://github.com/laravel/framework/issues/19391#issuecomment-418705976","issue_url":"https://api.github.com/repos/laravel/framework/issues/19391","id":418705976,"node_id":"MDEyOklzc3VlQ29tbWVudDQxODcwNTk3Ng==","user":{"login":"ChrisReid","id":2385373,"node_id":"MDQ6VXNlcjIzODUzNzM=","avatar_url":"https://avatars0.githubusercontent.com/u/2385373?v=4","gravatar_id":"","url":"https://api.github.com/users/ChrisReid","html_url":"https://github.com/ChrisReid","followers_url":"https://api.github.com/users/ChrisReid/followers","following_url":"https://api.github.com/users/ChrisReid/following{/other_user}","gists_url":"https://api.github.com/users/ChrisReid/gists{/gist_id}","starred_url":"https://api.github.com/users/ChrisReid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ChrisReid/subscriptions","organizations_url":"https://api.github.com/users/ChrisReid/orgs","repos_url":"https://api.github.com/users/ChrisReid/repos","events_url":"https://api.github.com/users/ChrisReid/events{/privacy}","received_events_url":"https://api.github.com/users/ChrisReid/received_events","type":"User","site_admin":false},"created_at":"2018-09-05T12:05:15Z","updated_at":"2018-09-05T12:05:15Z","author_association":"NONE","body":"@almokhtarbr as he said, it's not an issue in the framework. Should issues be left open indefinitely?"}}
{"actor":{"display_login":"ChrisReid"}}