{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/13680","repository_url":"https://api.github.com/repos/yiisoft/yii2","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/13680/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/13680/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/13680/events","html_url":"https://github.com/yiisoft/yii2/issues/13680","id":210726632,"number":13680,"title":"Implicit conversion from data type char to varbinary(max) is not allowed","user":{"login":"Schwoebel","id":1336569,"avatar_url":"https://avatars1.githubusercontent.com/u/1336569?v=4","gravatar_id":"","url":"https://api.github.com/users/Schwoebel","html_url":"https://github.com/Schwoebel","followers_url":"https://api.github.com/users/Schwoebel/followers","following_url":"https://api.github.com/users/Schwoebel/following{/other_user}","gists_url":"https://api.github.com/users/Schwoebel/gists{/gist_id}","starred_url":"https://api.github.com/users/Schwoebel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Schwoebel/subscriptions","organizations_url":"https://api.github.com/users/Schwoebel/orgs","repos_url":"https://api.github.com/users/Schwoebel/repos","events_url":"https://api.github.com/users/Schwoebel/events{/privacy}","received_events_url":"https://api.github.com/users/Schwoebel/received_events","type":"User","site_admin":false},"labels":[{"id":247756568,"url":"https://api.github.com/repos/yiisoft/yii2/labels/MSSQL","name":"MSSQL","color":"006b75","default":false},{"id":33208443,"url":"https://api.github.com/repos/yiisoft/yii2/labels/type:bug","name":"type:bug","color":"e102d8","default":false}],"state":"closed","locked":false,"assignee":{"login":"sergeymakinen","id":983964,"avatar_url":"https://avatars0.githubusercontent.com/u/983964?v=4","gravatar_id":"","url":"https://api.github.com/users/sergeymakinen","html_url":"https://github.com/sergeymakinen","followers_url":"https://api.github.com/users/sergeymakinen/followers","following_url":"https://api.github.com/users/sergeymakinen/following{/other_user}","gists_url":"https://api.github.com/users/sergeymakinen/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeymakinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeymakinen/subscriptions","organizations_url":"https://api.github.com/users/sergeymakinen/orgs","repos_url":"https://api.github.com/users/sergeymakinen/repos","events_url":"https://api.github.com/users/sergeymakinen/events{/privacy}","received_events_url":"https://api.github.com/users/sergeymakinen/received_events","type":"User","site_admin":false},"assignees":[{"login":"sergeymakinen","id":983964,"avatar_url":"https://avatars0.githubusercontent.com/u/983964?v=4","gravatar_id":"","url":"https://api.github.com/users/sergeymakinen","html_url":"https://github.com/sergeymakinen","followers_url":"https://api.github.com/users/sergeymakinen/followers","following_url":"https://api.github.com/users/sergeymakinen/following{/other_user}","gists_url":"https://api.github.com/users/sergeymakinen/gists{/gist_id}","starred_url":"https://api.github.com/users/sergeymakinen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergeymakinen/subscriptions","organizations_url":"https://api.github.com/users/sergeymakinen/orgs","repos_url":"https://api.github.com/users/sergeymakinen/repos","events_url":"https://api.github.com/users/sergeymakinen/events{/privacy}","received_events_url":"https://api.github.com/users/sergeymakinen/received_events","type":"User","site_admin":false},{"login":"SilverFire","id":4499203,"avatar_url":"https://avatars2.githubusercontent.com/u/4499203?v=4","gravatar_id":"","url":"https://api.github.com/users/SilverFire","html_url":"https://github.com/SilverFire","followers_url":"https://api.github.com/users/SilverFire/followers","following_url":"https://api.github.com/users/SilverFire/following{/other_user}","gists_url":"https://api.github.com/users/SilverFire/gists{/gist_id}","starred_url":"https://api.github.com/users/SilverFire/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SilverFire/subscriptions","organizations_url":"https://api.github.com/users/SilverFire/orgs","repos_url":"https://api.github.com/users/SilverFire/repos","events_url":"https://api.github.com/users/SilverFire/events{/privacy}","received_events_url":"https://api.github.com/users/SilverFire/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/yiisoft/yii2/milestones/23","html_url":"https://github.com/yiisoft/yii2/milestone/23","labels_url":"https://api.github.com/repos/yiisoft/yii2/milestones/23/labels","id":2082378,"number":23,"title":"2.0.13","description":"","creator":{"login":"cebe","id":189796,"avatar_url":"https://avatars0.githubusercontent.com/u/189796?v=4","gravatar_id":"","url":"https://api.github.com/users/cebe","html_url":"https://github.com/cebe","followers_url":"https://api.github.com/users/cebe/followers","following_url":"https://api.github.com/users/cebe/following{/other_user}","gists_url":"https://api.github.com/users/cebe/gists{/gist_id}","starred_url":"https://api.github.com/users/cebe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cebe/subscriptions","organizations_url":"https://api.github.com/users/cebe/orgs","repos_url":"https://api.github.com/users/cebe/repos","events_url":"https://api.github.com/users/cebe/events{/privacy}","received_events_url":"https://api.github.com/users/cebe/received_events","type":"User","site_admin":false},"open_issues":0,"closed_issues":341,"state":"closed","created_at":"2016-10-20T12:05:24Z","updated_at":"2017-11-03T10:27:51Z","due_on":"2017-07-09T07:00:00Z","closed_at":"2017-11-02T22:18:20Z"},"comments":1,"created_at":"2017-02-28T09:07:42Z","updated_at":"2017-11-03T19:54:52Z","closed_at":"2017-10-31T09:51:00Z","author_association":"NONE","body":"### What steps will reproduce the problem?\r\n\r\n```php\r\n    namespace app\\commands;\r\n\r\n    use app\\rbac\\IsYourSchoolRule;\r\n    use yii;\r\n    use yii\\console\\Controller;\r\n\r\n    class RbacController extends Controller\r\n    {\r\n\r\n      public function actionInit()\r\n      {\r\n        $auth = Yii::$app->authManager;\r\n        //Create our 4 Roles\r\n        $admin = $auth->createRole('admin');\r\n        $auth->add($admin);\r\n        $principal = $auth->createRole('Lokal-Admin');\r\n    $auth->add($principal);\r\n    $unit_admin = $auth->createRole('Chef');\r\n    $auth->add($unit_admin);\r\n    $teacher = $auth->createRole('Personal');\r\n    $auth->add($teacher);\r\n\r\n    //Assign roles in their descending order to their parent\r\n    $auth->addChild($admin, $principal);\r\n    $auth->addChild($principal, $unit_admin);\r\n    $auth->addChild($unit_admin, $teacher);\r\n\r\n    /*\r\n     * Initialize the Rule that restricts user-activity to only their assigned school\r\n     */\r\n    $rule = new IsYourSchoolRule;\r\n\r\n    //create the permission that allows a person to toggle any students attendance\r\n    $toggleAttendance = $auth->createPermission('toggleAttendance');\r\n    $toggleAttendance->description = 'Ändra närvaro';\r\n    $auth->add($toggleAttendance);\r\n    //Give this permission to toggle ANY students attendance exclusively to the admin.\r\n    $auth->addChild($principal, $toggleAttendance);\r\n\r\n    // add the rule\r\n    $auth->add($rule);\r\n    //Create the permission that will use this RuleClass to check if the user is assigned to the same school as the student\r\n    $toggleThisStudent = $auth->createPermission('toggleThisStudentsAttendance');\r\n    $toggleThisStudent->description = 'Ändra elevens närvaro';\r\n    $toggleThisStudent->ruleName = $rule->name;\r\n    //Add the permission to the DB\r\n    $auth->add($toggleThisStudent);\r\n    //Add this permission as a child of the toggle-any-student permission to establish a relation between the two\r\n    $auth->addChild($toggleAttendance, $toggleThisStudent);\r\n    //Add the toggle-student-assigned-to-your-school rule to any teacher\r\n    $auth->addChild($teacher, $toggleThisStudent);\r\n    //So now we should be able to Toggle any student in our school if we are a teacher, group-leader, or principal as\r\n    //long as they are assigned to a group that is in the same school as us.\r\n    //But if the user has the role of admin they should be able to toggle the attendance of anyone, regardless of\r\n    //school.\r\n\r\n\r\n\r\n    /*\r\n     * From here the process is a little less comment-y.  But it is following the same premise as explained in detail above.\r\n     * For this project it breaks down like this;\r\n     * 1.Create a broad-stroke rule.\r\n     * 2.Add it to the auth manager\r\n     * 3.Add it as a child of admin, since admin is the highest level of user.\r\n     * 4. Initialize the new RULE\r\n     * 5. add the RULE to the auth manager\r\n     * 6. create a Permission, as more or less a \"container\" to hold the rule so the authmanager has something to check\r\n     *  it against.  The auth manager can't simply check rules.  It only checks permissions\r\n     * 7. add the description and rule name for the permission.\r\n     * 8. add the permission to the auth manager\r\n     * 9. add the permission to the broad-stroke permission as a CHILD permisssion\r\n     * 10. add the permission that contains your rule to the lowest level role it should apply to.\r\n     *   That way if that role is a child of another role it will apply to that one too.\r\n     *\r\n     * Rinse. Repeat until all of the rules in the app\\rbac rolder have been added.\r\n     */\r\n\r\n    $createStudent = $auth->createPermission('addStudent');\r\n    $createStudent->description = 'Lägg till elev';\r\n    $auth->add($createStudent);\r\n    $auth->addChild($admin, $createStudent);\r\n\r\n    $createStudentForGroup = $auth->createPermission('addStudentToAssignedSchoolsGroups');\r\n    $createStudentForGroup->description = \"Create Student for a group in your school\";\r\n    $createStudentForGroup->ruleName = $rule->name;\r\n\r\n    $auth->add($createStudentForGroup);\r\n\r\n    $auth->addChild($createStudent, $createStudentForGroup);\r\n    $auth->addChild($unit_admin, $createStudentForGroup);\r\n\r\n\r\n\r\n    $moveStudent = $auth->createPermission('moveStudent');\r\n    $moveStudent->description = \"Move student between groups and/or schools\";\r\n    $auth->add($moveStudent);\r\n    $auth->addChild($admin, $moveStudent);\r\n\r\n    $moveStudentsBetweenGroupsInYourSchool = $auth->createPermission('moveStudentBetweenGroupsInTheSchoolYouAreAPartOf');\r\n    $moveStudentsBetweenGroupsInYourSchool->description = 'Move Students betweeen groups in YOUR school';\r\n    $moveStudentsBetweenGroupsInYourSchool->ruleName = $rule->name;\r\n\r\n    $auth->add($moveStudentsBetweenGroupsInYourSchool);\r\n\r\n    $auth->addChild($moveStudent, $moveStudentsBetweenGroupsInYourSchool);\r\n    $auth->addChild($unit_admin, $moveStudentsBetweenGroupsInYourSchool);\r\n\r\n\r\n    \r\n    $editStudent = $auth->createPermission('editStudent');\r\n    $editStudent->description = \"Edit Students\";\r\n    $auth->add($editStudent);\r\n    $auth->addChild($admin, $editStudent);\r\n\r\n    $editStudentsInYourGroup = $auth->createPermission('editStudentsInYourSchoolsGroups');\r\n    $editStudentsInYourGroup->description = 'Edit a Student that is in your schools groups';\r\n    $editStudentsInYourGroup->ruleName = $rule->name;\r\n\r\n    $auth->add($editStudentsInYourGroup);\r\n\r\n    $auth->addChild($editStudent, $editStudentsInYourGroup);\r\n    $auth->addChild($teacher, $editStudentsInYourGroup);\r\n\r\n\r\n\r\n    $addTeachers = $auth->createPermission('addTeacher');\r\n    $addTeachers->description = 'Lägg till lärare i grupp';\r\n    $auth->add($addTeachers);\r\n    $auth->addChild($admin, $addTeachers);\r\n\r\n    $addTeacherToYourSchool = $auth->createPermission('addTeacherToYourOwnSchool');\r\n    $addTeacherToYourSchool->description = 'Add a teacher to the school you are assigned to';\r\n    $addTeacherToYourSchool->ruleName = $rule->name;\r\n\r\n    $auth->add($addTeacherToYourSchool);\r\n\r\n    $auth->addChild($addTeachers, $addTeacherToYourSchool);\r\n    $auth->addChild($unit_admin, $addTeacherToYourSchool);\r\n\r\n    $addGroups = $auth->createPermission('addGroup');\r\n    $addGroups->description = 'Lägg till grupp i skola';\r\n    $auth->add($addGroups);\r\n    $auth->addChild($admin, $addGroups);\r\n\r\n    $addGroupToYourSchool = $auth->createPermission('addGroupToYourSchool');\r\n    $addGroupToYourSchool->description = \"Add a group to the school you are assigned to\";\r\n    $addGroupToYourSchool->ruleName = $rule->name;\r\n\r\n    $auth->add($addGroupToYourSchool);\r\n\r\n    $auth->addChild($addGroups, $addGroupToYourSchool);\r\n    $auth->addChild($principal, $addGroupToYourSchool);\r\n\r\n\r\n    $addSchool = $auth->createPermission('addSchool');\r\n    $addSchool->description = 'Lägg till skola';\r\n    $auth->add($addSchool);\r\n    $auth->addChild($admin, $addSchool);\r\n\r\n    $addUsersWithChildRoles = $auth->createPermission('addUser');\r\n    $addUsersWithChildRoles->description = \"Add users with roles below yours\";\r\n    $auth->add($addUsersWithChildRoles);\r\n    $auth->addChild($admin, $addUsersWithChildRoles);\r\n\r\n\r\n    $editProfile = $auth->createPermission('editProfile');\r\n    $editProfile->description = 'Edit User Profile';\r\n    $auth->add($editProfile);\r\n    $auth->addChild($admin, $editProfile);\r\n\r\n    // add the rule\r\n    $rule = new \\app\\rbac\\EditProfileRule;\r\n    $auth->add($rule);\r\n\r\n    // add the \"updateOwnPost\" permission and associate the rule with it.\r\n    $updateOwnProfile = $auth->createPermission('editOwnProfile');\r\n    $updateOwnProfile ->description = 'edit Own Profile';\r\n    $updateOwnProfile ->ruleName = $rule->name;\r\n    $auth->add($updateOwnProfile );\r\n\r\n    // \"updateOwnProfle\" will be used from \"updateProfile\"\r\n    $auth->addChild($updateOwnProfile, $editProfile);\r\n\r\n    // allow \"teacher\" to update their own profile\r\n    $auth->addChild($teacher, $updateOwnProfile);\r\n\r\n      }\r\n\r\n     }\r\n\r\n```\r\n\r\nThen run rbac/init\r\n### What is the expected result?\r\nThe file should populate the rbac DB with rule and role data\r\n### What do you get instead?\r\n    C:\\inetpub\\wwwroot\\kungalvs>php yii rbac/init Exception 'yii\\db\\Exception' with message     'SQLSTATE[42000]: [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Implicit conversion from data type char to varbinary(max) is not allowed. Use the CONVERT function to run this query.The SQL being executed was: INSERT INTO [auth_item] ([name], [type], [description], [rule_name], [data], [created_at], [updated_at]) VALUES ('admin', 1, NULL, NULL, NULL, 1488272331, 1488272331)'\r\n\r\n    in C:\\inetpub\\wwwroot\\kungalvs\\vendor\\yiisoft\\yii2\\db\\Schema.php:636\r\n\r\n    Error Info:\r\n    Array\r\n    (\r\n        [0] => 42000\r\n        [1] => 257\r\n        [2] => [Microsoft][ODBC Driver 11 for SQL Server][SQL Server]Implicit conversion from data     type char to varbinary(max) is not allowed. Use the CONVERT function to run this query.\r\n        )\r\n\r\n### Additional info\r\n\r\n| Q                | A\r\n| ---------------- | ---\r\n| Yii version      | 2.0.11.2\r\n| PHP version      | 5.6.24\r\n| Operating system | DB Driver 11 Microsoft Windows Server 2012 R2\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/341809955","html_url":"https://github.com/yiisoft/yii2/issues/13680#issuecomment-341809955","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/13680","id":341809955,"user":{"login":"samdark","id":47294,"avatar_url":"https://avatars2.githubusercontent.com/u/47294?v=4","gravatar_id":"","url":"https://api.github.com/users/samdark","html_url":"https://github.com/samdark","followers_url":"https://api.github.com/users/samdark/followers","following_url":"https://api.github.com/users/samdark/following{/other_user}","gists_url":"https://api.github.com/users/samdark/gists{/gist_id}","starred_url":"https://api.github.com/users/samdark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/samdark/subscriptions","organizations_url":"https://api.github.com/users/samdark/orgs","repos_url":"https://api.github.com/users/samdark/repos","events_url":"https://api.github.com/users/samdark/events{/privacy}","received_events_url":"https://api.github.com/users/samdark/received_events","type":"User","site_admin":false},"created_at":"2017-11-03T19:54:52Z","updated_at":"2017-11-03T19:54:52Z","author_association":"OWNER","body":"Please create new issue."}}
{"actor":{"display_login":"samdark"}}