[QGIS-Developer] substr expression 1-based? Others too?

Nathan Woodrow madmanwoo at gmail.com
Mon May 8 06:39:50 PDT 2017


Hey,

Postgres, SQL Server, etc are all 1 based. Hence the alignment with that
logic.

- Nathan

On Mon, May 8, 2017 at 11:31 PM, Richard Duivenvoorde <rdmailings at duif.net>
wrote:

> Hi Devs,
>
> Trying to create a rule based style I encountered/used the 'substr'
> function to find the first character of a field.
>
> Isn't it strange that this function is one based while in all languages
> I know this kind of function(s) are zero-based?
>
> now it is:
> substr('Hello',0,1) returns ''
> while I expected it to return 'H'
> but:
> substr('Hello',1,1) returns 'H'
>
> in QGIS3 there is also:
> substr('Hello',-1,1) returns 'o'  # ok
>
> Are more functions one-based instead of (the normal?) zero-based?
>
> Is it an idea to bring the expression(s) inline with other programming
> languages?
>
> Or is there a special reasoning not to do this?
>
> Regards,
>
> Richard
>
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20170508/a710092b/attachment.html>


More information about the QGIS-Developer mailing list