Open McCache opened 1 year ago
Ideally, it is better to have the DB definition in a single place. I would like to move away from text DDL script and just defined my entire DB model using the tools provided by V.
If I have my DB model in V, the next step is to emit DDL command for the targeted DB to create the schema. Here, having the comments populated into the DB for the DBAs would be nice.
SQLAlchemy is an example where I can use the model in Python and also use the model via Alembic to create the DB objects.
So you are asking for support for the SQL COMMENT
, like so:
CREATE TABLE accesslog (
aid int(10) NOT NULL auto_increment COMMENT 'unique ID for each access entry',
title varchar(255) default NULL COMMENT 'the title of the page being accessed',
path varchar(255) default NULL COMMENT 'the local path of teh page being accessed',
....
) TYPE=MyISAM;
Correct?
Unfortunately, I'm not sure if this can go in ORM, as it is supposed to support the same commands across all databases. The COMMENT statement only appears to exist for mysql and pgsql, but not for sqlite and many other databases.
In other words, COMMENT is an extension to the sql spec, not a part of the standard. And even though it does exist in both mysql and pgsql, it is implemented in very different ways between them. For example, pgsql requires the comment to be set in a completely different statement, after the CREATE TABLE. For example
create table session_log
(
userid int not null,
phonenumber int
);
comment on column session_log.userid is 'The user ID';
comment on column session_log.phonenumber is 'The phone number including the area code';
Generally speaking, it would be nice to capture some additional metadata so that some schema migration framework/tools can be built so that we can have a single tool to use in an ORM or install/update a schema. If we don't capture a little more that is needed by the ORM we will have to resolve to an extra external script. The vendor specific tool could use the extra metadata if they support it to create the DB objects.
For example, Python's Alembic is the vendor independent database database install and upgrade that is built on top of SQLAlcheny.
I like the fact that V provides an ORM which will be the single point of truth and I think we should stay with a single tool for uniformity and hopefully reduce complexity. For me, less is better.
Thanks.
On Fri, Oct 27, 2023 at 7:00 PM JalonSolov @.***> wrote:
Unfortunately, I'm not sure if this can go in ORM, as it is supposed to support the same commands across all databases. The COMMENT statement only appears to exist for mysql and pgsql, but not for sqlite and many other databases.
In other words, COMMENT is an extension to the sql spec, not a part of the standard. And even though it does exist in both mysql and pgsql, it is implemented in very different ways between them. For example, pgsql requires the comment to be set in a completely different statement, after the CREATE TABLE. For example
create table session_log ( userid int not null, phonenumber int ); comment on column session_log.userid is 'The user ID';comment on column session_log.phonenumber is 'The phone number including the area code';
— Reply to this email directly, view it on GitHub https://github.com/vlang/v/issues/19354#issuecomment-1783662801, or unsubscribe https://github.com/notifications/unsubscribe-auth/BB252FNFXXD2L5ARMHHEFLDYBRRKRAVCNFSM6AAAAAA4ZNKK7WVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOBTGY3DEOBQGE . You are receiving this because you authored the thread.Message ID: @.***>
Describe the feature
Current I don't see a
comment
filed in your documentation at: https://modules.vlang.io/orm.htmlUse Case
We need to document the table and the columns. When the table is a created the table and column comments shall be created in the target DB , if it is supported.
Proposed Solution
No response
Other Information
No response
Acknowledgements
Version used
master
Environment details (OS name and version, etc.)
Should be for all platform.