summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--internal/commands/billable_rate_test.go5
-rw-r--r--internal/commands/import.go8
-rw-r--r--internal/database/queries.sql4
-rw-r--r--internal/queries/queries.sql.go9
4 files changed, 14 insertions, 12 deletions
diff --git a/internal/commands/billable_rate_test.go b/internal/commands/billable_rate_test.go
index f9ce621..184d51f 100644
--- a/internal/commands/billable_rate_test.go
+++ b/internal/commands/billable_rate_test.go
@@ -174,8 +174,8 @@ func TestTimeEntryWithTimesCoalescing(t *testing.T) {
// Create time entry with times but no explicit rate - should use project rate
now := time.Now().UTC()
timeEntry, err := q.CreateTimeEntryWithTimes(context.Background(), queries.CreateTimeEntryWithTimesParams{
- StartTime: now,
- EndTime: sql.NullTime{Time: now.Add(time.Hour), Valid: true},
+ StartTime: now.Format(time.DateTime),
+ EndTime: now.Add(time.Hour).Format(time.DateTime),
Description: sql.NullString{String: "Test work", Valid: true},
ClientID: client.ID,
ProjectID: sql.NullInt64{Int64: project.ID, Valid: true},
@@ -222,4 +222,3 @@ func TestTimeEntryCoalescingWithoutProject(t *testing.T) {
t.Errorf("Expected billable_rate 7550, got %v", timeEntry.BillableRate)
}
}
-
diff --git a/internal/commands/import.go b/internal/commands/import.go
index a767923..a1d0d8f 100644
--- a/internal/commands/import.go
+++ b/internal/commands/import.go
@@ -186,9 +186,13 @@ func importSingleEntry(q *queries.Queries, entry clockifyEntry, loc *time.Locati
projectID = sql.NullInt64{Int64: project.ID, Valid: true}
}
+ // Format times as SQLite-compatible strings for the datetime() function
+ startTimeStr := startTime.UTC().Format(time.DateTime)
+ endTimeStr := endTime.UTC().Format(time.DateTime)
+
_, err = q.CreateTimeEntryWithTimes(context.Background(), queries.CreateTimeEntryWithTimesParams{
- StartTime: startTime.UTC(),
- EndTime: sql.NullTime{Time: endTime.UTC(), Valid: true},
+ StartTime: startTimeStr,
+ EndTime: endTimeStr,
Description: sql.NullString{String: entry.Description, Valid: entry.Description != ""},
ClientID: client.ID,
ProjectID: projectID,
diff --git a/internal/database/queries.sql b/internal/database/queries.sql
index b798cbf..073574a 100644
--- a/internal/database/queries.sql
+++ b/internal/database/queries.sql
@@ -118,8 +118,8 @@ select * from project where name = @name and client_id = @client_id limit 1;
-- name: CreateTimeEntryWithTimes :one
insert into time_entry (start_time, end_time, description, client_id, project_id, billable_rate)
values (
- @start_time,
- @end_time,
+ datetime(@start_time),
+ datetime(@end_time),
@description,
@client_id,
@project_id,
diff --git a/internal/queries/queries.sql.go b/internal/queries/queries.sql.go
index 3da8b98..1bd8ec1 100644
--- a/internal/queries/queries.sql.go
+++ b/internal/queries/queries.sql.go
@@ -8,7 +8,6 @@ package queries
import (
"context"
"database/sql"
- "time"
)
const createClient = `-- name: CreateClient :one
@@ -107,8 +106,8 @@ func (q *Queries) CreateTimeEntry(ctx context.Context, arg CreateTimeEntryParams
const createTimeEntryWithTimes = `-- name: CreateTimeEntryWithTimes :one
insert into time_entry (start_time, end_time, description, client_id, project_id, billable_rate)
values (
- ?1,
- ?2,
+ datetime(?1),
+ datetime(?2),
?3,
?4,
?5,
@@ -122,8 +121,8 @@ returning id, start_time, end_time, description, client_id, project_id, billable
`
type CreateTimeEntryWithTimesParams struct {
- StartTime time.Time
- EndTime sql.NullTime
+ StartTime interface{}
+ EndTime interface{}
Description sql.NullString
ClientID int64
ProjectID sql.NullInt64