I do find this syntax nice but the problem is it doesn't work
I'm not sure why but dup had trouble working inside macros. Maybe because it's
a macro itself and the macro resolution algorithm works in such a way that by
the time outer macro is resolved the inner one is not, so we're getting a
@reneha @cumulonimbus
Added an issue, feel free to discuss there:
[https://github.com/moigagoo/norm/issues/73](https://github.com/moigagoo/norm/issues/73)
Where would you store it? In the Model type? Or in a separate global variable?
You are right, update is a far from optimal operation in the current
implementation. In fact, it's even worse than you've described, because all
related objects are updated too. So for a single object, not only all its
columns are updated but also all columns of all its related objects even if
That almost made me cry :-) Thanks, it means a lot, really does
Did you have a chance to try out the new version?
> (And if you want a challenge, help us transition the NimForum to using Norm
> :D)
First, I need to update Norman, that's essential. But when I'm done, this
sounds like a fun
> I can imagine migrations that don't change the schema.
Data migrations can be done with `select` and `update`. Although data
migrations are generally unwanted.
> I'm not sure about the removal of migrations though, that will make it very
> hard to create any libraries/"plugins" as there won't be a standardized way
> of moving between versions.
You still can run migrations, you just write them in pure SQL.
Migrations are hard. Even if we take the most
> it is helpful to have a tracking of which schema is in the database and which
> one is expected by the code.
[Norman](https://moigagoo.github.io/norman/norman.html) is a migration manager
for Norm. It lets you apply and undo migrations, preserving order. I have to
update it for Norm 2,
> Doesn't this just waste performance creating a duplicate object that's going
> to be discarded?
To insert a row, you must first instantiate a model to hold the data for that
row. So, either way, you're creating an object, you can't avoid that.
The problem is that sometimes you don't care
Lessons learned:
1\. **Instances over typedescs.** With Norm 1, I inspected typedescs to
generate SQL queries. To do that, I had to implement an intermediate
representation layer for object definitions. This gave me more or less simple
API to inspect and modify object definitions at compile
the taste of the new, Nim 1.2.0-driven API, here's how you
filter and update rows (taken from
[tsqlitesugar.nim](https://github.com/moigagoo/norm/blob/develop/tests/tsqlitesugar.nim#L40)):
discard @[newToy()].dup:
dbConn.select("price > ?", 50)
appl
Hey, I see the new design had been released! Looks great, thanks!
Just want to say thank you for developing and maintaining Nimble directory. Use
it all the time.
I think yellow is the way to go, just gotta find a different shade that passes
the proximity test. Maybe more orange would do.
What's the best way to get a pragma value for each object field? We have
getCustomPragmaVal which accepts untyped. We also have fieldPairs which returns
field names as strings. But there's no way to call getCustomPragmaVal knowing
only the field name.
The best solution I came up with is macro
Hochnimisch.
You're discovering new platforms I see :-)
Try using webpack to ship your Nim modules:
[https://github.com/idle-z/nim-loader](https://github.com/idle-z/nim-loader)
Or having a talk at the upcoming online Nim conference.
I have a topic request: practical hot code reloading. So far, I couldn't make
it work for backend or frontend code. Not that I spent too much time trying,
but I believe it should just work. If someone could show how to make it just
work on a simple but practical example, that would be great.
For frontend, Karax is the way to go.
For backend, there are at least Jester and Rosencrantz.
There's no Nim-sponsored hosting solution, you can pick anyone you like. I used
to use Zeit when they offered Docker deployments. People say Heroku is nice.s
Thanks for the clarification!
I always thought the RFC was about the fancy syntax for default values, not the
fundamental ability to set them; that I assumed had been possible somehow.
Oh well, I'll use an explicit init proc then.
Hi!
How do I set a default value for a type that doesn't have any? For example, an
object or DateTime?
I know there's `default` proc that gets the default value for a given type but
I couldn't figure out how to use it.
I truly believe this is a fantastic idea, and we should make it happen.
However, it seems like the thread stagnated.
@Araq @dom96 maybe announce this in an official blog post?
Replaced the heading with bold text :-)
Sure, Google Form is nice. Maybe, a Google Spreadsheet would do too.
I suggest we list topics in this thread in the format:
Title
=
Run
Brief description.
One post—one topic.
Votes for talks is done with ❤.
I'll start by reformatting my own post.
Such a great idea, Andreas! I would like to showcase Nim for web with a
complete chat example.
I've done this talk at a local frontend conference, and it went pretty well,
despite me failing to run the app at the end (I promise to fix it this time ).
I'll cover Karax, WebSockets, and JS FFI.
I'm proud to announce the first release of **Norman** , the migration manager
for Norm:
[https://moigagoo.github.io/norman/norman.html](https://moigagoo.github.io/norman/norman.html)
With Norman, you can keep your DB config separate from the models in a project
config and generate, apply and
No, these are completely different. The first one runs `nim js`, the second one
`nim c -d:js`.
To compile Nim to JS, run `nim js myfile.nim`, simple as that.
To use modules from npm, use jsffi module
([https://nim-lang.org/docs/jsffi.html](https://nim-lang.org/docs/jsffi.html))
and Webpack with Nim loader
([https://github.com/bmollot/nim-loade)](https://github.com/bmollot/nim-loade\)).
I have a vision of Norm evolving to a compete framework someday. The ORM is
there, the migration manager is underway, we can then add a GraphQL wrapper
around Norm and add a layer for easy websocket communication between Karax
frontend and e.g. Jester or Rosencrantz backend.
If you use Norm, you can use logging module to log all generated queries, just
add import logging; addHandler newConsoleLogger()
I'm using it with Sublime Text. It more or less works, but there's one really
nasty issue: it won't see my local modules. So, I'm having a ton of errors all
the time.
Try completely removing your installation and installing Nim with choosenim. It
will show what needs to be added to PATH during installation.
Thanks! This is exactly what I was looking for.
I wish there was a way to mark the thread resolved.
The proposed solution works even without the intermediate template. If the arg
type is typed then the content of the included file is passed to the macro and
not the include statement.
However, there's still a problem with it. If the included module contains
macros, they are expanded before
Now I'm even more confused.
Tried this simple code:
import macros
macro foo(body: untyped): untyped =
echo treeRepr body
foo:
var x = 123
Run
This won't print anything to stdout. I could swear it should print the tree
representation of
Thanks for the tip! This won't compile unfortunately: Error: unhandled
exception: 'ident' is not accessible using discriminant 'kind' of type 'TNode'
[FieldError]
You don't install nimble files, you install packages. Nimble file is just meta
for a package. So downloading the file alone won't do.
When you've cloned the repo, you can run either nimble install` or `nimble
develop in the repo folder to install the package or install in development
mode
I need to find a db block in a module and copy it entirely to a new file.
So, I basically need a way to pass a module's code to a macro where I'll
iterate over its nodes to find the necessary one.
So far, I haven't found a way do so. Naïve attempts like this one don't work,
since I'm getting
Despite my fears, the entire Norm test suite runs in Nim devel with --gc:arc!
To make it happen, only [a few minor code
changes](https://github.com/moigagoo/norm/commit/551e11720b6a3aba75f02b4d43535f7b5d6efcde)
were necessary.
The future is now
llows you to use one connection for reading and another for writing.
> Did you think, open several connections
You mean connection pool? There's an [open
issue](https://github.com/moigagoo/norm/issues/50) for it, but I'm not planning
on taking on it any time soon. I plan to focus on the migra
://github.com/moigagoo/norm/blob/feature/58_insert_for_immutable_objects/src/norm/sqlite.nim#L170](https://github.com/moigagoo/norm/blob/feature/58_insert_for_immutable_objects/src/norm/sqlite.nim#L170)
Will report the issue to Nim.
Hi!
I've got this weird behavior with overloading, could anyone please advise if
it's a bug?
INim 0.4.1
Nim Compiler Version 1.0.6 [Windows: amd64] at
C:\Users\moigagoo\.nimble\bin\nim.exe
nim> proc foo(x: object): int = x.i*2
nim> proc foo(x: var object) =
It is my great pleasure to announce Norm version 1.1.0 release:
[https://moigagoo.github.io/norm/changelog.html](https://moigagoo.github.io/norm/changelog.html)
The biggest change addition are the procs to write migrations. With those in
place, I can focus on writing a migration manager that
.
3\. Why is a submodule ignored by `nim doc`` command? ``sqlite`` folder is
generated https://github.com/moigagoo/norm/tree/gh-pages/api/norm but
``postgres` is not, although they both exist in the code:
[https://github.com/moigagoo/norm/tree/develop/src/norm](https://github.com/moigagoo/norm/tree/develo
First, congrats! Seems like an important milestone, even if there's much to be
done ahead.
Second, what does arc in Nim mean for us mortals? Will compiling or running
programs become faster? Will we have to use a different mechanism to get type
information now that typeinfo is unavailable with
What font are you using?
Could you please elaborate? How to I store state of a VComponent and access it
from other components?
Thanks for the sample!
Do you use this xName naming convention to make procs look more like types?
Makes sense, just clarifying.
Also, how would you handle state in your app model?
I've tried exploring component-based architecture in Karax once:
[https://moigagoo.svbtle.com/exploring-karax](https://moigagoo.svbtle.com/exploring-karax)
However, I now see there is VCompoment type in Karax and there are
examples/tests that demonstrate its usage.
Is this the official way to
Could this be because Jester uses HttpBeast in Linux and builtin server on
FreeBSD?
Well I have the raw recordings somewhere on OneDrive. I can share a link if you
want.
Podcast is a great idea but I underestimated how much time and effort it
requires.
I just want to clarify that there's no problem with plain Datetime, m just init
it explicitly like I do in tests and norm-sample-webapp. It's none Datetime
that is the real issue.
What are the types of your model fields? I'm getting these warnings when using
Option[Datetime] because Datetime doesn't have a default value. To make things
worse, you can't solve it even with manual initialization: `none Datetime`
still doesn't initialize a Datetime object which throws the
GCC and wget manually:
[https://github.com/moigagoo/nimage/blob/develop/flavors/slim.nim#L8](https://github.com/moigagoo/nimage/blob/develop/flavors/slim.nim#L8)
Base images for Ubuntu and Alpine don't include GCC ¯_(ツ)_/¯
These 19 MB probably don't include GCC and git and curl and other packages
necessary to build Nim.
Removed `c_code` from the Docker images, which got them **almost three times**
thinner, from 1.3 GB to 527 MB. Thanks, @charlieH!
If you find a way to reduce the installment size, please consider contributing
to the Docker images at moigagoo/nimage.
Nim only does the Nim code to C | C++ | JS code transformation. C | C++ to
binary is done by a C | C++ compiler.
Updated the Docker images:
[https://cloud.docker.com/u/nimlang/repository/docker/nimlang/nim/tags](https://cloud.docker.com/u/nimlang/repository/docker/nimlang/nim/tags)
You probably haven't added nimble packages dir to your PATH. Also, you should
install Nim with choose I'm. Scoop is awesome, but choosenim is the way to go
these days.
It turns our other types are not passed as I expected too. SqlQuery is passed
as string, which conforms to what @jlp765 said about reprs.
> debugEcho is showing you the table repr
debugInfo shows different things when called in different places. When called
at the end of the proc that returns the table, it prints the table properly.
When called downstream on the called proc result, it prints the implementation
details. So, even
Hi!
In Norm, I'm parsing type section at compile time and generate the db schema
from it. Currently, a seq[SqlQuery] is generated with code like this:
proc genTableSchema(dbObjRepr: ObjRepr, dbObjReprs: openArray[ObjRepr]):
SqlQuery =
## Generate table schema for an object
Nim's `pass` is called `discard`.
In Norm 1.0.15 (released just now), you can split DC schema definition across
multiple modules.
In order to do that. wrap the type section you want to use in schema in
`dbTypes`` macro and use ``dbFromTypes`` instead of ``db`. See example in the
docs (scroll down to “Alternatively to
Here's a PR I'm developing this feature in:
[https://github.com/moigagoo/norm/pull/26](https://github.com/moigagoo/norm/pull/26)
Feel free to comment.
Sorry, I don't think I follow your point. Could you please try to illustrate it
with some examples? Or we could connect directly and chat about it in Russian
if you want.
No, you shouldn't.
There's an open PR that implements dbAddObject proc that allows to add type
definitions from different module to the global model definition. This may be
the thing that could help you: define types in modules as you'd normally do,
then glue them together in models.nim module.
I'll try to
You probably mean a static method of a class, like Python @staticmethod
decorated methods.
In Nim, methods are just functions called with dot syntax. And static methods
are just functions that don't do anything with their object argument.
What are you trying to achieve? Python and Nim are
OP sounds like a professional offendee.
Surely the term "fascism" was used in a broader sense than you're sticking to.
Replace it with "totalitarianism" if you feel better this way.
Anyway, that’s cheap word picking irrelevant to the topic discussed. I believe
the thread should be removed, and
timestamps, and in PostgreSQL native TIMESTAMP WITH
TIME ZONE is used.
Changelog:
[https://github.com/moigagoo/norm/blob/develop/changelog.md](https://github.com/moigagoo/norm/blob/develop/changelog.md)
As before, you are free to use a custom parser and formatter for any type.
These are just sane
Use times.format with explicitly defined time zone or, which I think is better,
store everything in UTC and ensure that by calling times.utc.
Although I am Russian and can understand what you're saying, please keep it
English on this forum. Rules are rules, and it's our responsibility as
community members to keep the information universally available to everyone.
Dominik is Polish and Andreas is German but they write and speak
In general, you don't change the state of the page with redirects in SPAS. You
just render the needed state and update the URL.
I am so interested in knowing the answer to this one. Couldn't find a way to do
that, had to use overloading. Works fine but feel like a hack rather than an
idiomatic solution.
I agree. Doesn't look right despite being technically valid.
I have some great news: Norm 1.0.11 supports inserting and retrieving NULL
values for SQLite databases.
This was made possible thanks to the great
[ndb](https://github.com/xzfc/ndb.nim) module. The transition from std
db_sqlite to ndb/sqlite was really smooth. I can't wait to see ndb replace
I've uploaded a new kind of Docker image to the Hub, based on choosenim instead
of manually built binaries:
[https://cloud.docker.com/u/nimlang/repository/docker/nimlang/choosenim](https://cloud.docker.com/u/nimlang/repository/docker/nimlang/choosenim)
So, if you need an image for Nim 0.20.0
WSL provides a nice convenient way to compile on Linux.
Updated Docker images:
[https://hub.docker.com/r/nimlang/nim/tags](https://hub.docker.com/r/nimlang/nim/tags)
support safe value substitution when constructing
queries, so you can safely pass user-provided data to it.
There's a breaking change: instead of `where` and `orderBy`, we now have a
single `cond` arg.
Feel free to use, report issues, and contribute:
[https://github.com/moigagoo/norm](https
> Nimpretty does ship with Nim.
No it's not:
$ wget https://nim-lang.org/download/nim-0.19.4_x64.zip
$ unzip nim-0.19.4_x64.zip
$ ls nim-0.19.4/bin/*.exe
nim-0.19.4/bin/nim.exe* nim-0.19.4/bin/nimble.exe*
nim-0.19.4/bin/nimgrab.exe* nim-0.19.4/bin/nimgrep.exe*
On a separate note, Nim itself could ship with nimpretty since its already in
the same repo anyway. This idea was dismissed in favor of moving nimpretty into
a separate nimble package but that necer happened. And if that's the plan, than
why aren't we following the same decision for choosenim?
What glibc version is required? Should both Linux and Windows versions be built
with it?
Automated builds are great but I can't see how we can set up them fast,
especially Windows builds.
However, I can compile Windows and Linux 32 and 64 bit versions right now and
upload them to the repo. If someone could compile an OSX build, we could call
it a release and think about automating
Also, it seems that Linux and OSX builds are already automated by Travis:
[https://github.com/dom96/choosenim/blob/master/.travis.yml](https://github.com/dom96/choosenim/blob/master/.travis.yml)
Does that mean that only Windows builds are missing?
Can I help? Are there pending PRs to be reviewed that you want included in the
new release? Maybe, critical issues?
What's blocking a new choosenim release?
Hi! No need to get aggressive :-) There are bugs out there, no doubt about
that. Any help reporting and fixing them is very much appreciated.
Could you please [report the
issue](https://github.com/nim-lang/Nim/issues/new?template=bug_report.md)?
Thanks for the idea! Sounds easy to implement. How do I store NULLs in an
object though? Maybe, allow fields to be nil besides their own type?
Thanks for the links! I didn't know about nim_sqlbuilder, I may switch to it
instead of using my own `rowutils` module.
I just want to make it clear that Norm is my first attempt to ORM and that
decisions I've made may be wrong. Any advice from seasoned developers is highly
appreciated.
Also, I'd be happy to see Norm evolve into a usable tool, so input from its
potential users is vital.
;, "foo"]` is converted
into 123, 123.123, "foo".
AFAIK Nim db modules' rows are always sequences of string regardless of the
underlying DB types. So I'm relying on the target object's types. You can see
the code that does the conversions in
[rowutils](https://github.com/moiga
> You can probably use custom pragmas: > > {.pragma: dbTime, dbType: "INTEGER",
> parseIt: timeparser, formatIt: timeformatter.}
You sure can, thanks for the tip!
Just a little sidenote: `parseIt` pragma is used to set an `it` expression
whereas `parser` is used to set a parser proc. So the
Thanks for the positive comment! It means a lot to me, for real.
Currently, there's no way to shorten or reuse field definition, and `DateTime`
is considered a special case, so _right now_ , unfortunately, it's `birthDate
{.dbType: "INTEGER", parseIt: it.parseInt().fromUnix().local(), formatIt:
something I'm not entire embarassed to share with the
community: [Norm](https://github.com/moigagoo/norm).
Norm turns `type` sections into a DB schema and provides ready to use CRUD
procs to query the data. Norm tries to be as thin as possible, so by default
object fields are mapped directly to DB
1 - 100 of 173 matches
Mail list logo