MySQL compatibility: specify VARCHAR length
`db.types.string` becomes now `db.types.string(n)` `db.types.text` is the wrong type to use (text blobs)
This commit is contained in:
parent
68974c4c40
commit
17b26ec23e
@ -1824,11 +1824,11 @@ def init(telegram_bot: Bot,
|
|||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'command',
|
'command',
|
||||||
db.types.string
|
db.types.string(100)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'description',
|
'description',
|
||||||
db.types.string
|
db.types.string(300)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'hidden',
|
'hidden',
|
||||||
|
@ -255,23 +255,39 @@ class Bot(TelegramBot, ObjectWithDatabase, MultiLanguageObject):
|
|||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'username',
|
'username',
|
||||||
self.db.types.string
|
self.db.types.string(64)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'first_name',
|
'first_name',
|
||||||
self.db.types.string
|
self.db.types.string(64)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'last_name',
|
'last_name',
|
||||||
self.db.types.string
|
self.db.types.string(64)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'language_code',
|
'language_code',
|
||||||
self.db.types.string
|
self.db.types.string(8)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'selected_language_code',
|
'selected_language_code',
|
||||||
self.db.types.string
|
self.db.types.string(8)
|
||||||
|
)
|
||||||
|
if 'user_profile_photos' not in self.db.tables:
|
||||||
|
table = self.db.create_table(
|
||||||
|
table_name='user_profile_photos'
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'user_id',
|
||||||
|
self.db.types.integer
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'telegram_file_id',
|
||||||
|
self.db.types.string(128)
|
||||||
|
)
|
||||||
|
table.create_column(
|
||||||
|
'update_datetime',
|
||||||
|
self.db.types.datetime
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@ class ObjectWithDatabase(object):
|
|||||||
"""Instantiate object and open connection with database."""
|
"""Instantiate object and open connection with database."""
|
||||||
if database_url is None:
|
if database_url is None:
|
||||||
database_url = 'database.db'
|
database_url = 'database.db'
|
||||||
if ':///' not in database_url:
|
if '://' not in database_url:
|
||||||
# Default database engine is sqlite, which operates on a
|
# Default database engine is sqlite, which operates on a
|
||||||
# single-file database having `.db` extension
|
# single-file database having `.db` extension
|
||||||
if not database_url.endswith('.db'):
|
if not database_url.endswith('.db'):
|
||||||
|
@ -262,7 +262,7 @@ def init(telegram_bot: davtelepot.bot.Bot, suggestion_messages=None):
|
|||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'suggestion',
|
'suggestion',
|
||||||
types.text
|
types.string(2048)
|
||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'created',
|
'created',
|
||||||
|
@ -664,7 +664,7 @@ def init(telegram_bot: Bot, useful_tools_messages=None):
|
|||||||
)
|
)
|
||||||
table.create_column(
|
table.create_column(
|
||||||
'expression',
|
'expression',
|
||||||
types.string
|
types.string(8192)
|
||||||
)
|
)
|
||||||
|
|
||||||
@telegram_bot.command(command='/calc',
|
@telegram_bot.command(command='/calc',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user