From cf9ea896817fff543e071de820d7af03077b1603 Mon Sep 17 00:00:00 2001 From: Simon Binder Date: Sat, 13 Mar 2021 14:56:06 +0100 Subject: [PATCH] moor_generator: Support the math extension --- docs/pages/docs/Advanced Features/builder_options.md | 2 ++ moor_generator/lib/src/analyzer/options.dart | 6 ++++++ moor_generator/lib/src/analyzer/options.g.dart | 1 + moor_generator/lib/src/analyzer/session.dart | 1 + 4 files changed, 10 insertions(+) diff --git a/docs/pages/docs/Advanced Features/builder_options.md b/docs/pages/docs/Advanced Features/builder_options.md index 9f8195dc..ed0ea753 100644 --- a/docs/pages/docs/Advanced Features/builder_options.md +++ b/docs/pages/docs/Advanced Features/builder_options.md @@ -100,6 +100,8 @@ We currently support the following extensions: Functions like `highlight` or `bm25` are available as well. - `moor_ffi`: Enables support for functions that are only available when using `moor_ffi`. This contains `pow`, `sqrt` and a variety of trigonometric functions. Details on those functions are available [here]({{ "../Other engines/vm.md#moor-only-functions" }}). +- `math`: Assumes that sqlite3 was compiled with [math functions](https://www.sqlite.org/lang_mathfunc.html). + This module is largely incompatible with the `moor_ffi` module. ## Recommended options diff --git a/moor_generator/lib/src/analyzer/options.dart b/moor_generator/lib/src/analyzer/options.dart index 12e2b617..86598923 100644 --- a/moor_generator/lib/src/analyzer/options.dart +++ b/moor_generator/lib/src/analyzer/options.dart @@ -129,4 +129,10 @@ enum SqlModule { // note: We're ignoring the warning because we can't change the json key // ignore: constant_identifier_names moor_ffi, + + /// Enables support for [built in math functions][math funs] when analysing + /// sql queries. + /// + /// [math funs]: https://www.sqlite.org/lang_mathfunc.html + math, } diff --git a/moor_generator/lib/src/analyzer/options.g.dart b/moor_generator/lib/src/analyzer/options.g.dart index 846d30ac..38c4b152 100644 --- a/moor_generator/lib/src/analyzer/options.g.dart +++ b/moor_generator/lib/src/analyzer/options.g.dart @@ -133,4 +133,5 @@ const _$SqlModuleEnumMap = { SqlModule.json1: 'json1', SqlModule.fts5: 'fts5', SqlModule.moor_ffi: 'moor_ffi', + SqlModule.math: 'math', }; diff --git a/moor_generator/lib/src/analyzer/session.dart b/moor_generator/lib/src/analyzer/session.dart index 1f768ddd..68c121a9 100644 --- a/moor_generator/lib/src/analyzer/session.dart +++ b/moor_generator/lib/src/analyzer/session.dart @@ -44,6 +44,7 @@ class MoorSession { if (options.hasModule(SqlModule.fts5)) const Fts5Extension(), if (options.hasModule(SqlModule.json1)) const Json1Extension(), if (options.hasModule(SqlModule.moor_ffi)) const MoorFfiExtension(), + if (options.hasModule(SqlModule.math)) const BuiltInMathExtension(), ], );