Commit Graph

20818 Commits

Author SHA1 Message Date
ringabout
a6997fb8eb fixes ptr to cstring warnings[backport] (#20848)
* fix =#13790 ptr char (+friends) should not implicitly convert to cstring

* Apply suggestions from code review

* first round; compiles on windows

* nimPreviewSlimSystem

* conversion is unsafe, cast needed

* fixes more tests

* fixes asyncnet

* another try another error

* last one

* true

* one more

* why bugs didn't show at once

* add `nimPreviewCstringConversion` switch

* typo

* fixes ptr to cstring warnings[backport]

* add fixes

Co-authored-by: xflywind <43030857+xflywind@users.noreply.github.com>
2022-11-16 17:22:51 +08:00
Andrey Makarov
d0cc21e322 Markdown code blocks migration part 7 (#20547) 2022-10-12 17:13:43 +03:00
ringabout
769869c699 refactor dbFormat (#19746)
* refactor dbFormat

* add simple tests
2022-09-29 18:16:42 +08:00
Andrey Makarov
344d861247 Implement Pandoc Markdown concise link extension (#20304)
* Implement Pandoc Markdown concise link extension

This implements https://github.com/nim-lang/Nim/issues/20127.
Besides reference to headings we also support doing references
to Nim symbols inside Nim modules.

Markdown:
```
Some heading
------------

Ref. [Some heading].
```

Nim:
```
proc someFunction*() ...

... ## Ref. [someFunction]
```

This is substitution for RST syntax like `` `target`_ ``.
All 3 syntax variants of extension from Pandoc Markdown are supported:
`[target]`, `[target][]`, `[description][target]`.

This PR also fixes clashes in existing files, particularly
conflicts with RST footnote feature, which does not work with
this PR (but there is a plan to adopt a popular [Markdown footnote
extension](https://pandoc.org/MANUAL.html#footnotes) to make footnotes work).

Also the PR fixes a bug that Markdown links did not work when `[...]`
section had a line break.

The implementation is straightforward since link resolution did not
change w.r.t. RST implementation, it's almost only about new syntax
addition. The only essential difference is a possibility to add a custom
link description: form `[description][target]` which does not have an
RST equivalent.

* fix nim 1.0 gotcha
2022-09-04 21:52:21 +03:00
ee7
a3eb2381f2 make implicit cstring conversions explicit (#19488)
The Nim manual says that an implicit conversion to cstring will
eventually not be allowed [1]:

    A Nim `string` is implicitly convertible to `cstring` for convenience.

    [...]

    Even though the conversion is implicit, it is not *safe*: The garbage collector
    does not consider a `cstring` to be a root and may collect the underlying
    memory. For this reason, the implicit conversion will be removed in future
    releases of the Nim compiler. Certain idioms like conversion of a `const` string
    to `cstring` are safe and will remain to be allowed.

And from Nim 1.6.0, such a conversion triggers a warning [2]:

    A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning.
    This warning will become an error in future versions! Use an explicit conversion
    like `cstring(x)` in order to silence the warning.

However, some files in this repo produced such a warning. For example,
before this commit, compiling `parsejson.nim` would produce:

    /foo/Nim/lib/pure/parsejson.nim(221, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]
    /foo/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]

This commit resolves the most visible `CStringConv` warnings, making the
cstring conversions explicit.

[1] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/doc/manual.md#cstring-type
[2] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/changelogs/changelog_1_6_0.md#type-system
2022-08-19 21:40:53 +02:00
Danil Yarantsev
2834588250 Change stdlib imports to use std prefix in most examples (#17202) 2021-03-01 00:17:19 +03:00
flywind
05f1ddc34c use single backtick (#17100) 2021-02-19 00:47:21 -06:00
shirleyquirk
234ecc42fa odbc regression from #14357 (#15417)
#14357 changed from sending 'val', an int, to a pointer to int, which is understandable, but not how SQLSetEnvAttr works.
"Depending on the value of Attribute, ValuePtr will be a 32-bit integer value or point to a null-terminated character string"
2020-09-29 16:08:24 +01:00
cooldome
36a191c9e6 fix sqlgetdata regression in odbc (#15161)
* fix sqlgetdata import

* fix db_odbc

* more fixes

* fix style
2020-08-07 21:37:54 +01:00
Bung
246b6e3ae0 add insert,tryInsert unify for postgres that need pk name (#14416)
* add insert,tryInsert unify for postgres that need pk name
* add ReadDbEffect to new procs
* add .since and changelog
* change since to 1.3
* Update src/db_postgres.nim

Co-authored-by: bung87 <crc32@qq.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: alaviss <leorize+oss@disroot.org>
2020-05-23 01:24:52 +08:00
Bung
53836903d3 fix #9771 (#14357)
* fix #9771
* map SQLLEN SQLULEN
* fix proc params take TSqlLen

Co-authored-by: bung87 <crc32@qq.com>
2020-05-16 03:00:06 +08:00
Andrew Owen
900d65ae91 Fix typo in docs (#12356) [ci skip] 2019-10-04 00:40:15 -06:00
Federico Ceratto
a17c1f85c3 Fix spellings (#12277) [backport] 2019-09-27 06:02:54 +01:00
Huy
31c1148eb0 add unsafeColumnAt procs, that return unsafe cstring from InstantRow (#11647) 2019-07-10 19:56:09 +07:00
Zed
2702689fe7 Fix header inconsistencies in documentation (#11071) 2019-04-23 08:40:20 +02:00
Andreas Rumpf
c337a17fb0 Merge branch 'devel' into araq-quirky-exceptions 2019-02-08 17:18:17 +01:00
Araq
40e8c2d744 removes deprecated T/P types 2018-11-16 13:27:46 +01:00
Araq
541d93bd90 docs: remove most stale links; refs #9109 2018-09-29 11:23:29 +02:00
Andreas Rumpf
16c646c816 Merge branch 'jlp765-db_odbc2' into devel 2016-05-28 20:12:29 +02:00
Araq
aaf7187fe5 resolved merge conflicts 2016-03-29 15:30:44 +02:00
Araq
255c7670c9 Merge branch 'devel' of https://github.com/nim-lang/Nim into devel 2016-01-18 14:54:50 +01:00
Araq
1cc74251ee Merge branch 'devel' of https://github.com/nim-lang/Nim into devel 2016-01-18 10:55:23 +01:00
ringabout
0ed7f08bed refactor dbFormat (#19746)
* refactor dbFormat

* add simple tests
2022-09-29 18:16:42 +08:00
Andrey Makarov
9b7320d352 Implement Pandoc Markdown concise link extension (#20304)
* Implement Pandoc Markdown concise link extension

This implements https://github.com/nim-lang/Nim/issues/20127.
Besides reference to headings we also support doing references
to Nim symbols inside Nim modules.

Markdown:
```
Some heading
------------

Ref. [Some heading].
```

Nim:
```
proc someFunction*() ...

... ## Ref. [someFunction]
```

This is substitution for RST syntax like `` `target`_ ``.
All 3 syntax variants of extension from Pandoc Markdown are supported:
`[target]`, `[target][]`, `[description][target]`.

This PR also fixes clashes in existing files, particularly
conflicts with RST footnote feature, which does not work with
this PR (but there is a plan to adopt a popular [Markdown footnote
extension](https://pandoc.org/MANUAL.html#footnotes) to make footnotes work).

Also the PR fixes a bug that Markdown links did not work when `[...]`
section had a line break.

The implementation is straightforward since link resolution did not
change w.r.t. RST implementation, it's almost only about new syntax
addition. The only essential difference is a possibility to add a custom
link description: form `[description][target]` which does not have an
RST equivalent.

* fix nim 1.0 gotcha
2022-09-04 21:52:21 +03:00
Andrey Makarov
03a0fda1bd Markdown code blocks part 6 (#20292) 2022-09-01 02:39:02 +03:00
ee7
730580382c make implicit cstring conversions explicit (#19488)
The Nim manual says that an implicit conversion to cstring will
eventually not be allowed [1]:

    A Nim `string` is implicitly convertible to `cstring` for convenience.

    [...]

    Even though the conversion is implicit, it is not *safe*: The garbage collector
    does not consider a `cstring` to be a root and may collect the underlying
    memory. For this reason, the implicit conversion will be removed in future
    releases of the Nim compiler. Certain idioms like conversion of a `const` string
    to `cstring` are safe and will remain to be allowed.

And from Nim 1.6.0, such a conversion triggers a warning [2]:

    A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning.
    This warning will become an error in future versions! Use an explicit conversion
    like `cstring(x)` in order to silence the warning.

However, some files in this repo produced such a warning. For example,
before this commit, compiling `parsejson.nim` would produce:

    /foo/Nim/lib/pure/parsejson.nim(221, 37) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]
    /foo/Nim/lib/pure/parsejson.nim(231, 39) Warning: implicit conversion to 'cstring' from a non-const location: my.buf; this will become a compile time error in the future [CStringConv]

This commit resolves the most visible `CStringConv` warnings, making the
cstring conversions explicit.

[1] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/doc/manual.md#cstring-type
[2] https://github.com/nim-lang/Nim/blob/d2318d9ccfe6/changelogs/changelog_1_6_0.md#type-system
2022-08-19 21:40:53 +02:00
ringabout
ea15babc09 fixes #20153; do not escape _ for mysql [backport] (#20164)
* fixes #20153; do not escape `_` for mysql

* add a test

* Update db_mysql.nim

* Update tdb_mysql.nim

Co-authored-by: Clay Sweetser <Varriount@users.noreply.github.com>
2022-08-06 05:15:58 +08:00
flywind
eb1a2176e7 enable style:usages for stdlib tests [backport: 1.6] (#19715)
* enable style:usages for stdlib tests

* freeAddrInfo

* more tests

* importc

* bufSize

* fix more

* => parseSql and renderSql
2022-04-13 17:53:02 +08:00
Danil Yarantsev
ce00e9284f Change stdlib imports to use std prefix in most examples (#17202) 2021-03-01 00:17:19 +03:00
flywind
942694fd46 use single backtick (#17100) 2021-02-19 00:47:21 -06:00
Andreas Rumpf
abee78c3b0 fixes db_mysql broken quoting; refs c16ee37a71 (r44209990) [backport:1.4] (#16035) 2020-11-18 23:06:16 +01:00
Andreas Rumpf
4ea64743cb fixes #15560 (#15587) 2020-10-15 15:49:00 +02:00
Bung
d0bc5875b0 Fix #15219 SQL escape in db_mysql is not enough (#15234) 2020-09-04 17:04:27 +08:00
Bung
51b0bd3121 add insert,tryInsert unify for postgres that need pk name (#14416)
* add insert,tryInsert unify for postgres that need pk name
* add ReadDbEffect to new procs
* add .since and changelog
* change since to 1.3
* Update src/db_postgres.nim

Co-authored-by: bung87 <crc32@qq.com>
Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: alaviss <leorize+oss@disroot.org>
2020-05-23 01:24:52 +08:00
Andreas Rumpf
e5a46907ab use system.move instead of system.shallowCopy if the GC mode requires it 2019-10-03 16:46:09 +02:00
Huy
4f663a104e add unsafeColumnAt procs, that return unsafe cstring from InstantRow (#11647) 2019-07-10 19:56:09 +07:00
Zed
ec08afd847 Fix header inconsistencies in documentation (#11071) 2019-04-23 08:40:20 +02:00
Araq
021fe523b1 removes deprecated T/P types 2018-11-16 13:27:46 +01:00
Andreas Rumpf
26afc0703a fixes merge conflict 2018-08-19 15:14:03 +02:00
Andreas Rumpf
8c93fc2229 fixed merge conflict 2018-06-04 16:16:50 +02:00
Andreas Rumpf
e8b734dde1 fixes #7200 2018-02-10 16:41:38 +01:00
pgkos
4b4613fc57 Fix segfault in db_mysql fastRows (#5605) 2017-03-26 09:42:15 +02:00
Araq
14c0c64c59 Merge branch 'devel' of https://github.com/nim-lang/Nim into devel 2016-01-18 14:54:50 +01:00
Araq
68eab87dd2 Merge branch 'devel' of https://github.com/nim-lang/Nim into devel 2016-01-18 10:55:23 +01:00
Dominik Picheta
a9c1a94037 Merge branch 'jlp765-db_mysqlExamples' into devel 2015-09-05 21:15:25 +01:00
Andreas Rumpf
4be74a1d20 Merge pull request #3289 from nanoant/patch/fix-whitespace
Patch/fix whitespace
2015-09-04 23:37:59 +02:00
Andreas Rumpf
bed7bc325f Merge pull request #3264 from jlp765/db_mysql
fixes #3220 src/db_mysql.nim getValue()
2015-09-03 14:09:43 +02:00
Andreas Rumpf
ce8659ac36 Merge pull request #2866 from nanoant/patch/db-deffered-rows
db: InstantRow and instantRows
2015-06-10 11:06:36 +02:00
pdw
d02789dd6e lib/impure - Dropped 'T' from types 2015-05-24 22:24:07 -05:00
Andreas Rumpf
e745c73dea Merge pull request #2337 from kemege/db_charset
Add character set options when opening DB connection, default to UTF-8
2015-03-17 01:32:26 +01:00