|
14 | 14 | * |
15 | 15 | * uuid4() - generate a version 4 UUID as a string |
16 | 16 | * uuid7() - generate a version 7 UUID as a string |
17 | | - * uuid7(X) - generate a version 7 UUID as a string using X seconds since the unix epoch as the timestamp |
| 17 | + * uuid7(X) - generate a version 7 UUID as a string |
| 18 | + * with a unix timestamp of X seconds. |
18 | 19 | * uuid_str(X) - convert a UUID X into a well-formed UUID string |
19 | 20 | * uuid_blob(X) - convert a UUID X into a 16-byte blob |
20 | 21 | * uuid7_timestamp_ms(X) - extract unix timestamp in miliseconds |
@@ -191,11 +192,12 @@ static void uuid_v7_generate(sqlite3_context* context, int argc, sqlite3_value** |
191 | 192 | (void)argv; |
192 | 193 |
|
193 | 194 | struct timespec ts; |
194 | | - if (argc == 1 && sqlite3_value_type(argv[0])==SQLITE_INTEGER) { |
195 | | - sqlite3_int64 seconds = sqlite3_value_int64(argv[0]); |
196 | | - ts.tv_sec = seconds; |
| 195 | + if (argc == 1 && sqlite3_value_type(argv[0]) == SQLITE_INTEGER) { |
| 196 | + sqlite3_int64 seconds = sqlite3_value_int64(argv[0]); |
| 197 | + ts.tv_sec = seconds; |
| 198 | + ts.tv_nsec = 0; |
197 | 199 | } else { |
198 | | - timespec_get(&ts, TIME_UTC); |
| 200 | + timespec_get(&ts, TIME_UTC); |
199 | 201 | } |
200 | 202 | unsigned long long timestampMs = ts.tv_sec * 1000ULL + ts.tv_nsec / 1000000; |
201 | 203 |
|
@@ -272,7 +274,8 @@ int uuid_init(sqlite3* db) { |
272 | 274 | sqlite3_create_function(db, "uuid4", 0, flags, 0, uuid_v4_generate, 0, 0); |
273 | 275 | sqlite3_create_function(db, "gen_random_uuid", 0, flags, 0, uuid_v4_generate, 0, 0); |
274 | 276 | #ifndef SQLEAN_OMIT_UUID7 |
275 | | - sqlite3_create_function(db, "uuid7", -1, flags, 0, uuid_v7_generate, 0, 0); |
| 277 | + sqlite3_create_function(db, "uuid7", 0, flags, 0, uuid_v7_generate, 0, 0); |
| 278 | + sqlite3_create_function(db, "uuid7", 1, flags, 0, uuid_v7_generate, 0, 0); |
276 | 279 | sqlite3_create_function(db, "uuid7_timestamp_ms", 1, det_flags, 0, uuid_v7_extract_timestamp_ms, |
277 | 280 | 0, 0); |
278 | 281 | #endif |
|
0 commit comments