diff options
author | Sébastien Dailly <sebastien@dailly.me> | 2025-02-13 18:30:34 +0100 |
---|---|---|
committer | Sébastien Dailly <sebastien@dailly.me> | 2025-02-13 18:30:43 +0100 |
commit | 67320d8f04e1f302306b9aafdaaf4bafcf443839 (patch) | |
tree | 48ab0f3e3a500d44309b9cf6d440c3f8ecce31ee | |
parent | d3e0821b9c1551177afb34220d951b087acdea22 (diff) |
Ignore the dates outside of the julian period
-rw-r--r-- | lib/sql/date.ml | 5 | ||||
-rw-r--r-- | tests/sql_functions.ml | 5 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/sql/date.ml b/lib/sql/date.ml index e8933c7..b1a8d6a 100644 --- a/lib/sql/date.ml +++ b/lib/sql/date.ml @@ -14,6 +14,11 @@ let f : Sqlite3.Data.t -> Sqlite3.Data.t -> Sqlite3.Data.t = in Sqlite3.Data.INT period with + | CalendarLib.Date.Out_of_bounds -> + prerr_endline + @@ Printf.sprintf "Date ignored (outside of Julian period): %s" + content; + Sqlite3.Data.NULL | Invalid_argument e -> prerr_endline e; Sqlite3.Data.NULL) diff --git a/tests/sql_functions.ml b/tests/sql_functions.ml index 524e793..56563fa 100644 --- a/tests/sql_functions.ml +++ b/tests/sql_functions.ml @@ -16,6 +16,11 @@ let test_suit = check "parsing int date" int_date (ImportSQL.Date.f format_date int_date) ); + ( "Parse out of bound date" >:: fun () -> + let text_date = Sqlite3.Data.TEXT "4002-04-08" + and format_date = Sqlite3.Data.TEXT "%Y-%m-%d" in + check "Out of bound" Sqlite3.Data.NULL + (ImportSQL.Date.f format_date text_date) ); ( "Parse regex" >:: fun _ -> let text = Sqlite3.Data.TEXT "hello world" and regex = Sqlite3.Data.TEXT "hello ([A-Za-z]+)" in |