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

Quotes are not added in text values ​​by default: SQL error: near "-": syntax error #195

Open
devmark404 opened this issue Dec 10, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@devmark404
Copy link

Environment:

  • OS: Windows
  • Godot version: 4.3
  • godot-sqlite version: 4.4

Issue description:
I try to create a table with a default text

func create_table_tests() -> void:
	var table = {
		"id": {
			"data_type": "int", 
			"primary_key": true, 
			"auto_incremental": true, 
			"not_null": true
		},
		"date": {
			"data_type": "TEXT",
			"default": '2001-01-01 01:01:01'
		}
	}
	db.create_table("tests", table)
	
	pass

When creating it, the following error appears:
--> SQL error: near "-": syntax error

If I activate the verbosity mode
db.verbosity_level = SQLite.VerbosityLevel.VERBOSE

I see that the following query is being made:

CREATE TABLE IF NOT EXISTS tests (id INTEGER PRIMARY KEY NOT NULL,date TEXT DEFAULT 2001-01-01 01:01:01);

The error occurs because this date should have quotes:
date TEXT DEFAULT 2001-01-01 01:01:01

ok:
date TEXT DEFAULT '2001-01-01 01:01:01'

However, those quotes are not added when I add default text in the query

@devmark404 devmark404 added the bug Something isn't working label Dec 10, 2024
@2shady4u
Copy link
Owner

Hello @devmark404 😄

This can be solved by encapsulating the offending string in an additional pair of (double or single) quotes, see here: #42

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants