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

ORM need to support comments #19354

Open
2 tasks
McCache opened this issue Sep 15, 2023 · 4 comments
Open
2 tasks

ORM need to support comments #19354

McCache opened this issue Sep 15, 2023 · 4 comments
Labels
Feature Request This issue is made to request a feature.

Comments

@McCache
Copy link

McCache commented Sep 15, 2023

Describe the feature

Current I don't see a comment filed in your documentation at:
https://modules.vlang.io/orm.html

Use 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

  • I may be able to implement this feature request
  • This feature might incur a breaking change

Version used

master

Environment details (OS name and version, etc.)

Should be for all platform.

Important

You can vote for this issue using the 👍 reaction. More votes increase the issue's priority
for developers.

Take into account that only the 👍 reaction counts as a vote.
Only reactions to the issue itself will be counted as votes, not comments.

@McCache McCache added the Feature Request This issue is made to request a feature. label Sep 15, 2023
@McCache
Copy link
Author

McCache commented Sep 15, 2023

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.

@JalonSolov
Copy link
Contributor

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?

@JalonSolov
Copy link
Contributor

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';

@McCache
Copy link
Author

McCache commented Oct 28, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

2 participants