Skip to content

Commit

Permalink
Another attempt at #3187
Browse files Browse the repository at this point in the history
  • Loading branch information
dmoagx committed Oct 2, 2018
1 parent 51381ca commit 7dbd044
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Models/SPUserManager.xcdatamodel/contents
Expand Up @@ -9,6 +9,7 @@
<attribute name="create_view_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="db" attributeType="String" maxValueString="64" indexed="YES" syncable="YES"/>
<attribute name="delete_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="delete_versioning_rows_priv" optional="YES" attributeType="Boolean" syncable="YES"/>
<attribute name="drop_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="event_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="execute_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
Expand All @@ -21,7 +22,6 @@
<attribute name="show_view_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="trigger_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="update_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="delete_history_priv" optional="YES" attributeType="Boolean" usesScalarValueType="NO" syncable="YES"/>
<attribute name="userManager" optional="YES" transient="YES" syncable="YES"/>
<relationship name="user" optional="YES" minCount="1" maxCount="1" deletionRule="Nullify" destinationEntity="SPUser" inverseName="schema_privileges" inverseEntity="SPUser" indexed="YES" syncable="YES"/>
</entity>
Expand All @@ -36,6 +36,7 @@
<attribute name="create_user_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="create_view_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="delete_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="delete_versioning_rows_priv" optional="YES" attributeType="Boolean" syncable="YES"/>
<attribute name="drop_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="event_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="execute_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
Expand Down Expand Up @@ -69,7 +70,6 @@
<attribute name="super_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="trigger_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="update_priv" optional="YES" attributeType="Boolean" defaultValueString="NO" syncable="YES"/>
<attribute name="delete_history_priv" optional="YES" attributeType="Boolean" usesScalarValueType="NO" syncable="YES"/>
<attribute name="user" optional="YES" attributeType="String" syncable="YES"/>
<attribute name="userManager" optional="YES" transient="YES" syncable="YES"/>
<relationship name="children" optional="YES" toMany="YES" minCount="1" deletionRule="Cascade" destinationEntity="SPUser" inverseName="parent" inverseEntity="SPUser" indexed="YES" syncable="YES"/>
Expand Down
15 changes: 10 additions & 5 deletions Source/SPUserManager.m
Expand Up @@ -101,12 +101,17 @@ - (id)init
// is derived automatically. While most keys can be automatically converted without
// any difficulty, some keys differ slightly in mysql column storage to GRANT syntax;
// this dictionary provides mappings for those values to ensure consistency.

// key is: The name of the actual column in the mysql.users / mysql.db table
// value is: The "Privilege" value from "SHOW PRIVILEGES" with " " replaced by "_" and "_priv" appended
privColumnToGrantMap = [@{
@"Grant_priv": @"Grant_option_priv",
@"Show_db_priv": @"Show_databases_priv",
@"Create_tmp_table_priv": @"Create_temporary_tables_priv",
@"Repl_slave_priv": @"Replication_slave_priv",
@"Repl_client_priv": @"Replication_client_priv",
@"Grant_priv": @"Grant_option_priv",
@"Show_db_priv": @"Show_databases_priv",
@"Create_tmp_table_priv": @"Create_temporary_tables_priv",
@"Repl_slave_priv": @"Replication_slave_priv",
@"Repl_client_priv": @"Replication_client_priv",
@"Truncate_versioning_priv": @"Delete_versioning_rows_priv", // MariaDB only, 10.3.4 only
@"Delete_history_priv": @"Delete_versioning_rows_priv", // MariaDB only, since 10.3.5
} retain];

schemas = [[NSMutableArray alloc] init];
Expand Down

0 comments on commit 7dbd044

Please sign in to comment.