Thinking on SQL and strings

Thinking on SQL and strings

https://github.com/tothpaul/DelphiTips/tree/master/SQLStrings

In fact, I'd like to have such feature at compile time :)
https://github.com/tothpaul/DelphiTips/tree/master/SQLStrings

Comments

  1. BTW is it possible to write something like that ?

    var
    v: TSQLString;
    s: string;
    begin
    v := s;
    end;

    I would like to avoid the TSQLString.Init() call but I can't see a way to do that.

    even this code override v to a variant string loosing the SQLString stuffs

    var
    v: Variant;
    s: string;
    begin
    TSQLString.Init(v, '');
    v := s; // v is no more a SQLString
    end;

    ReplyDelete
  2. Jacek Laskowski I know, but AFAIK there's no Assign operator, Delphi just clear the target variant before changing it's type to vtString

    ReplyDelete
  3. Paul TOTH but did you try this trick? :-)

    class function &&op_Implicit(a: string): TSQLString;

    ReplyDelete
  4. Jacek Laskowski TSQLString is not a type, it's a Variant handler...don't see where I could put the operator...

    ReplyDelete
  5. Paul TOTH Okay, I've read about the custom variant, so ... you have a problem, sorry :-)
    Maybe it will be useful ...

    lnssoftware.ca - Steve’s Blog » Blog Archive » Custom Variants in Delphi

    ReplyDelete
  6. Attila Kovacs you cannot switch a 10 years old project to ORM with a wizard wand, but you can simplify your work with simple concepts like this SQLString

    ReplyDelete

Post a Comment