protected override DataTable ReadTable(DataConnectionWrapper connection, object[] restrictions, string sort) { DataTable dt = base.ReadTable(connection, restrictions, sort); return(MySqlConnectionSupport.ConvertAllBinaryColumns(dt)); }
/// <summary> /// Reads table with Database Objects which satisfy given restriction. Applies filter for aditional restriction /// if MySQL version is less then 5.0. /// </summary> /// <param name="connection">The DataConnectionWrapper to be used for enumeration.</param> /// <param name="restrictions">The restrictions to be putted on the retrieved objects set.</param> /// <param name="sort">Sort expresion to append after ORDER BY clause.</param> /// <returns>Returns table with Database Objects which satisfy given restriction.</returns> protected override DataTable ReadTable(DataConnectionWrapper connection, object[] restrictions, string sort) { if (connection == null) { throw new ArgumentNullException("connection"); } // Use base method to read table DataTable first_result = base.ReadTable(connection, restrictions, sort); // fixup collation names DataTable result = MySqlConnectionSupport.ConvertAllBinaryColumns(first_result); // If there is now result from bas, return immediately if (result == null) { return(result); } // Extract server version Version serverVersion = connection.ServerVersion; // For latest version just call base if (serverVersion == null || serverVersion.Major >= 5) { return(result); } // For legacy version apply restrictions to result manualy (first slot - character set name, third slot - flag is default) // At first check if there is any restrictions if (restrictions == null || restrictions.Length <= 0) { return(result); } if (String.IsNullOrEmpty(restrictions[0] as String) && (restrictions.Length < 3 || String.IsNullOrEmpty(restrictions[2] as String))) { return(result); } // Iterates through rows and filter them foreach (DataRow collation in result.Select()) { // Apply character set name filter if (!String.IsNullOrEmpty(restrictions[0] as String) && !DataInterpreter.CompareInvariant( restrictions[0] as String, DataInterpreter.GetStringNotNull(collation, Attributes.CharacterSetName))) { collation.Delete(); continue; } // Apply is_default constraint if (restrictions.Length >= 3 && !String.IsNullOrEmpty(restrictions[2] as String) && !DataInterpreter.CompareInvariant( restrictions[2] as String, DataInterpreter.GetStringNotNull(collation, Attributes.IsDefault))) { collation.Delete(); continue; } } // Accept changes and return results result.AcceptChanges(); return(result); }