setType($type); $this->database->select("account", "*"); $this->assertQuery( "SELECT * FROM "account"", $this->database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @dataProvider typesProvider */ public function testSelectTableWithAlias($type) { $this->setType($type); $this->database->select("account (user)", "name"); $this->assertQuery( "SELECT "name"\nFROM "account" AS "user"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectSingleColumn($type) { $this->setType($type); $this->database->select("account", "name"); $this->assertQuery( "SELECT "name"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumns($type) { $this->setType($type); $this->database->select("account", ["name", "id"]); $this->assertQuery( "SELECT "name","id"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithAlias($type) { $this->setType($type); $this->database->select("account", ["name(nickname)", "id"]); $this->assertQuery( "SELECT "name" AS "nickname","id"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithType($type) { $this->setType($type); $this->database->select("account", ["name[String]", "data [JSON]"]); $this->assertQuery( "SELECT "name","data"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithAliasAndType($type) { $this->setType($type); $this->database->select("account", ["name (nickname) [String]", "data [JSON]"]); $this->assertQuery( "SELECT "name" AS "nickname","data"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectColumnsWithRaw($type) { $this->setType($type); $this->database->select("account", [ "id [String]" => Medoo::raw("UUID()") ]); $this->assertQuery( "SELECT UUID() AS "id"\nFROM "account"", $this->database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @covers ::isJoin() * @dataProvider typesProvider */ public function testSelectWithWhere($type) { $this->setType($type); $this->database->select("account", [ "name", "id" ], [ "ORDER" => "age" ]); $this->assertQuery( "SELECT "name","id"\nFROM "account"\nORDER BY "age"", $this->database->queryString ); } /** * @covers ::select() * @covers ::selectContext() * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithLeftJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nLEFT JOIN "post"\nUSING ("user_id")", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithRightJoin($type) { $this->setType($type); $this->database->select("account", [ "[<]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nRIGHT JOIN "post"\nUSING ("user_id")", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithFullJoin($type) { $this->setType($type); $this->database->select("account", [ "[<>]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nFULL JOIN "post"\nUSING ("user_id")", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithInnerJoin($type) { $this->setType($type); $this->database->select("account", [ "[><]post" => "user_id" ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nINNER JOIN "post"\nUSING ("user_id")", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithSameKeysJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]photo" => ["user_id", "avatar_id"], ], [ "account.name", "photo.link" ]); $this->assertQuery( "SELECT "account"."name","photo"."link"\nFROM "account"\nLEFT JOIN "photo"\nUSING ("user_id", "avatar_id")", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithKeyJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => ["user_id" => "author_id"], ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nLEFT JOIN "post"\nON "account"."user_id" = "post"."author_id"", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithAliasJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post (main_post)" => ["user_id" => "author_id"], ], [ "account.name", "main_post.title" ]); $this->assertQuery( "SELECT "account"."name","main_post"."title"\nFROM "account"\nLEFT JOIN "post" AS "main_post"\nON "account"."user_id" = "main_post"."author_id"", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithReferJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => ["user_id" => "author_id"], "[>]album" => ["post.author_id" => "user_id"], ], [ "account.name", "post.title", "album.link" ]); $this->assertQuery( "SELECT "account"."name","post"."title","album"."link"\nFROM "account"\nLEFT JOIN "post"\nON "account"."user_id" = "post"."author_id"\nLEFT JOIN "album"\nON "post"."author_id" = "album"."user_id"", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithMultipleConditionJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]album" => ["author_id" => "user_id"], "[>]post" => [ "user_id" => "author_id", "album.user_id" => "owner_id" ] ], [ "account.name", "post.title", "album.link" ]); $this->assertQuery( "SELECT "account"."name","post"."title","album"."link"\nFROM "account"\nLEFT JOIN "album"\nON "account"."author_id" = "album"."user_id"\nLEFT JOIN "post"\nON "account"."user_id" = "post"."author_id"\nAND "album"."user_id" = "post"."owner_id"", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectWithAdditionalConditionJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => [ "user_id" => "author_id", "AND" => [ "post.id[>]" => 10 ] ] ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nLEFT JOIN "post"\nON "account"."user_id" = "post"."author_id"\nAND "post"."id" > 10", $this->database->queryString ); } /** * @covers ::isJoin() * @covers ::buildJoin() * @dataProvider typesProvider */ public function testSelectRawJoin($type) { $this->setType($type); $this->database->select("account", [ "[>]post" => Medoo::raw("ON = ") ], [ "account.name", "post.title" ]); $this->assertQuery( "SELECT "account"."name","post"."title"\nFROM "account"\nLEFT JOIN "post"\nON "account"."user_id" = "post"."author_id"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectAllWithJoin($type) { $this->setType($type); $this->expectException(InvalidArgumentException::class); $this->database->select("account", [ "[>]post" => "user_id" ], [ "account.*" ]); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDataMapping($type) { $this->setType($type); $this->database->select("post", [ "[>]account" => ["user_id"] ], [ "post.content", "userData" => [ "account.user_id", "account.email", "meta" => [ "account.location", "account.gender" ] ] ]); $this->assertQuery( "SELECT "post"."content","account"."user_id","account"."email","account"."location","account"."gender"\nFROM "post"\nLEFT JOIN "account"\nUSING ("user_id")", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithIndexMapping($type) { $this->setType($type); $this->database->select("account", [ "user_id" => [ "name (nickname)", "location" ] ]); $this->assertQuery( "SELECT "user_id","name" AS "nickname","location"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDistinct($type) { $this->setType($type); $this->database->select("account", [ "@location", "nickname" ]); $this->assertQuery( "SELECT DISTINCT "location","nickname"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithDistinctDiffOrder($type) { $this->setType($type); $this->database->select("account", [ "location", "@nickname" ]); $this->assertQuery( "SELECT DISTINCT "nickname","location"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithUnicodeCharacter($type) { $this->setType($type); $this->database->select("considérer", [ "name (名前)", "положение (ロケーション)" ]); $this->assertQuery( "SELECT "name" AS "名前","положение" AS "ロケーション"\nFROM "considérer"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithHyphenCharacter($type) { $this->setType($type); $this->database->select("account", [ "nick-name" ]); $this->assertQuery( "SELECT "nick-name"\nFROM "account"", $this->database->queryString ); } /** * @covers ::columnMap() * @covers ::columnPush() * @dataProvider typesProvider */ public function testSelectWithSingleCharacter($type) { $this->setType($type); $this->database->select("a", [ "[>]e" => ["f"] ], [ "b (c)" ]); $this->assertQuery( "SELECT "b" AS "c"\nFROM "a"\nLEFT JOIN "e" USING ("f")", $this->database->queryString ); } } __halt_compiler();----SIGNATURE:----G3veg1kdJgrZoPWHz03Z33MW1ePZCQz/krQN0QbCYmqnkn1UGw8OOi4ulS5+uMWReyX6p1DR6ofjYYeGGQUWZjik9KtMTIfaTC7gEr+/z91b4tBz59vWnM1P8DfAxYfQWfn6aw9lpAv4b60WHgFaLCHgVkPYJvO0uwjnx1No2ihOxq7PfdLbzDRMuimD0YKyQON21q86ksr/d3zZseV1i6QjenfZTsT4tHhcUlUQWq88KLJWJP47oRwpP+PGyKCcu567dfLcRUfh2FqNyGkf0QhB22gDxe5CrDocwHMUjsRZBhfaa/ZyoTdF/Qyh7Fc81Zu+GDkV88zqx6shC63zRN2UfUkmKJ6A15sZOuE/1HM57uptPo8hfLj5TEiO5D97ruakow5/Dj+aLhMfNgHMnyUvyR14/vB8114q4bU5664bQ7ntu8unrdfqdn7IGim+0H3JNAASFArKlLnDupPZEA8i98ZHpR8OVo1nQdMaFpr9LsdK1mY2vX88bM/nfpKV/g9EJddESrKTgTzdoTyKltB/uTOmufKY2dzC6hEqn46qkLGSrrUTmhR3GFJTKiZbB9pE5i7E36NmGiu24pkfQjkEH7LwJ5keKhEJz8xGAG45RQaT7I7Ccqyl+jl7XS9ypSA4SjX/l8xUIrsKbSxNefIEVR7JY4T4afc2OiziDO8=----ATTACHMENT:----NzMyMjI0NDA1MDI4MDYwNiA2MDE4Mzg0OTE0OTM1MTkwIDQ5NTM5NjIyNDcyMDA4NzM=