Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

mysql: timestamp datetype. #18704

Merged
merged 1 commit into from Jun 29, 2023
Merged

Conversation

walkingdevel
Copy link
Contributor

@walkingdevel walkingdevel commented Jun 28, 2023

Fixes #18234

struct Test {
	id int [primary; serial]
	time1 time.Time
	time2 time.Time [sql_type: 'timestamp']
}

fn main() {
	mut db := mysql.connect(...)!

	test := Test{
		time1: time.now()
		time2: time.now()
	}

	sql db {
		create table Test
	}!

	sql db {
		insert test into Test
	}!

	tests := sql db {
		select from Test
	}!

	println(tests)

	// [Test{
	//    id: 0
	//    time1: 2023-06-28 18:00:51
	//    time2: 2023-06-28 18:00:51
	//}]
}

馃 Generated by Copilot at d56940a

Add timestamp support to MySQL ORM. This allows working with timestamp columns and values in vlib/db/mysql/orm.v.

馃 Generated by Copilot at d56940a

  • Allocate memory for timestamp data pointers in vlib/db/mysql/orm.v (link)
  • Set buffer type to blob for timestamp bind parameters in vlib/db/mysql/orm.v (link)
  • Convert timestamp data to time.Time values in V in vlib/db/mysql/orm.v (link)
  • Format time.Time values as strings for timestamp columns in vlib/db/mysql/orm.v (link)

@spytheman spytheman merged commit 7ee2584 into vlang:master Jun 29, 2023
36 checks passed
@walkingdevel walkingdevel deleted the fix-mysql-timestamp branch June 29, 2023 05:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement the timestamp datatype for MySQL/MariaDB
2 participants