dsync icon indicating copy to clipboard operation
dsync copied to clipboard

Use sql comments as output by `diesel print-schema`, if present

Open SamuelMarks opened this issue 1 year ago • 7 comments

How should this be supported? - I'm thinking:

CREATE TABLE "profiles" (
    alias             VARCHAR(50) PRIMARY KEY    -- user-modifiable alias
);

Or maybe:

COMMENT ON COLUMN profiles.alias IS 'user-modifiable alias';

Or something else? - What do you think?

Here's the current code FWIW: https://github.com/Wulf/dsync/blob/2797966/src/code.rs#L360

SamuelMarks avatar Dec 03 '24 00:12 SamuelMarks

I do not understand what this feature request is. Are you asking to support using column documentation from the raw .sql files? If that is the case, then dsync will very likely not support that as dsync only reads the schema.rs file as output by diesel print-schema. If in the future that command should output those comments, then it would be a good option to add such a thing to dsync.

hasezoey avatar Dec 03 '24 00:12 hasezoey

Ok so you're saying I should send a PR to diesel with this?

Is there a preferred way you want it, e.g., one of the approaches I just mentioned?

SamuelMarks avatar Dec 03 '24 00:12 SamuelMarks

Is there a preferred way you want it, e.g., one of the approaches I just mentioned?

That is better asked the diesel developers.

Ok so you're saying I should send a PR to diesel with this?

Yes, dsync does not read the raw sql files or interacts with any live databases, it only reads schema.rs which is generated by diesel print-schema, which in turn does interact with live databases (IIRC).

PS: diesel print-schema already outputs some comments, just not from the sql file(s) or the live database to my knowledge, see this example output.

hasezoey avatar Dec 03 '24 00:12 hasezoey

Ok I've made a new issue on diesel; would appreciate your commentary there if you have an opinion :)

https://github.com/diesel-rs/diesel/discussions/4375

SamuelMarks avatar Dec 03 '24 01:12 SamuelMarks

Considering that https://github.com/diesel-rs/diesel/discussions/4375 mentions that print-schema --with-docs already reads and output sql comments, it is reasonable to re-open this issue.

hasezoey avatar Dec 03 '24 13:12 hasezoey

Great. Checking in on this issue; need a hand for the implementation side @hasezoey ?

SamuelMarks avatar Dec 19 '24 16:12 SamuelMarks

@SamuelMarks if you want to make a PR for it, you can. I am currently not really developing dsync, but will review and merge if possible.

hasezoey avatar Dec 19 '24 16:12 hasezoey