microsoft / microsoft/go-sqlcmd

Consider enabling custom date and time format strings provided by the user

Open
#80 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
595
Forks
91
Avg merge
9h 35m
Merged PRs (30d)
1

Description

We don't have a way to get the user's locale information, particularly on non-Windows platforms.
As part of the fix for #77 I am going to implement the standard format strings for the TSQL date and time types. It'd be cool if users could provide their own format strings mapped to a given SQL type.

For example, the default format string in go for a DATETIME will be 2006-01-02 15:04:05.000

the time package in Go defines a bunch of constants for common layouts:

const (
	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
	ANSIC       = "Mon Jan _2 15:04:05 2006"
	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
	RubyDate    = "Mon Jan 02 15:04:05 -0700 2006"
	RFC822      = "02 Jan 06 15:04 MST"
	RFC822Z     = "02 Jan 06 15:04 -0700" // RFC822 with numeric zone
	RFC850      = "Monday, 02-Jan-06 15:04:05 MST"
	RFC1123     = "Mon, 02 Jan 2006 15:04:05 MST"
	RFC1123Z    = "Mon, 02 Jan 2006 15:04:05 -0700" // RFC1123 with numeric zone
	RFC3339     = "2006-01-02T15:04:05Z07:00"
	RFC3339Nano = "2006-01-02T15:04:05.999999999Z07:00"
	Kitchen     = "3:04PM"
	// Handy time stamps.
	Stamp      = "Jan _2 15:04:05"
	StampMilli = "Jan _2 15:04:05.000"
	StampMicro = "Jan _2 15:04:05.000000"
	StampNano  = "Jan _2 15:04:05.000000000"
)

We could define either environment variables or create a new config file for sqlcmd where users can set the format string associated with each TSQL date type. If we use environment variables we can incorporate them into the regular set of SQLCMD variables so scripts could assign it using :setvar

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the standard date and time formatting work described in #77 and Go's time package layouts. Then trace how sqlcmd formats TSQL date and time values and how SQLCMD variables are handled. Done means users can provide per-type format strings through the chosen configuration mechanism and see the expected output.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
cli, databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.