Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backward compatible schema discovery for MySQL 5.6 #86

Merged
merged 5 commits into from
Nov 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/mysql/query/column.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{InformationSchema, SchemaQueryBuilder};
use crate::sqlx_types::mysql::MySqlRow;
use sea_query::{Expr, Iden, Order, Query, SeaRc, SelectStatement};
use sea_query::{Expr, Iden, Order, Query, SeaRc, SelectStatement, Value};

#[derive(Debug, sea_query::Iden)]
/// Ref: https://dev.mysql.com/doc/refman/8.0/en/information-schema-columns-table.html
Expand Down Expand Up @@ -48,16 +48,24 @@ impl SchemaQueryBuilder {
table: SeaRc<dyn Iden>,
) -> SelectStatement {
Query::select()
.columns(vec![
.columns([
ColumnFields::ColumnName,
ColumnFields::ColumnType,
ColumnFields::IsNullable,
ColumnFields::ColumnKey,
ColumnFields::ColumnDefault,
ColumnFields::Extra,
ColumnFields::GenerationExpression,
ColumnFields::ColumnComment,
])
.conditions(
self.system.is_mysql() && self.system.version >= 50700,
|q| {
q.column(ColumnFields::GenerationExpression);
},
|q| {
q.expr(Expr::val(Value::String(None)));
},
)
.column(ColumnFields::ColumnComment)
.from((InformationSchema::Schema, InformationSchema::Columns))
.and_where(Expr::col(ColumnFields::TableSchema).eq(schema.to_string()))
.and_where(Expr::col(ColumnFields::TableName).eq(table.to_string()))
Expand Down
2 changes: 1 addition & 1 deletion src/mysql/query/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl SchemaQueryBuilder {
q.column(StatisticsFields::Expression);
},
|q| {
q.expr(Expr::val(Value::Bool(None)));
q.expr(Expr::val(Value::String(None)));
},
)
.from((InformationSchema::Schema, InformationSchema::Statistics))
Expand Down