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

if table name is "order" it will report an error,should add char `` to table #27

Open
rhettli opened this issue Dec 8, 2022 · 0 comments

Comments

@rhettli
Copy link

rhettli commented Dec 8, 2022

such as sql:
SHOW CREATE TABLE `order` # ok

SHOW CREATE TABLE order # error

here is code below:

func createTableSQL(db *sql.DB, name string) (string, error) {
	// Get table creation SQL
	var table_return sql.NullString
	var table_sql sql.NullString

        // fix it like this,thanks
	err := db.QueryRow("SHOW CREATE TABLE `"+name+"`").Scan(&table_return, &table_sql)

	if err != nil {
		return "", err
	}
	if table_return.String != name {
		return "", errors.New("Returned table is not the same as requested table")
	}

	return table_sql.String, nil
}
@rhettli rhettli changed the title if table name is "order" it will report an error,show add char `` to table if table name is "order" it will report an error,should add char `` to table Dec 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant