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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModeledResponse.Model.Id is inconsistent with ModeledResponse.Content.Id #102

Open
nor0x opened this issue Nov 11, 2024 · 0 comments
Open
Labels
bug Something isn't working

Comments

@nor0x
Copy link

nor0x commented Nov 11, 2024

Bug report

I have the following data model for a repro:

[Table("movies")]
public class Movie : BaseModel
{
	[PrimaryKey("id", true)]
	public Guid Id { get; private set; }
	[Column("title")]
	public string Title { get; set; }

	[Column("created_at")]
	public DateTime CreatedAt { get; set; }

	public Movie()
	{
		Id = Guid.NewGuid();
	}
}

note that I did set [PrimaryKey("id", true)] because I need to handle Ids locally in a database. When I run the command to insert a new Movie object the Id is set correctly.

var newMovie = new Movie { Title = "Some Movie" };
Console.WriteLine("new movie: " + newMovie.Title + " " + newMovie.Id);
//prints: new movie: Some Movie SOMEGUID


var insertResponse = await supabase.From<Movie>().Insert(newMovie);
Console.WriteLine("insert response: " + insertResponse.Content);
//prints [{"id":"SOMEGUID","created_at":"0001-01-01T00:00:00+00:00","title":"Some Movie"}]

After the command to retrieve the movie the Id has a different value eventhough the content json has the correct one

Console.WriteLine("getting movies");
var moviesResponse = await supabase.From<Movie>().Get();
Console.WriteLine("content: " + moviesResponse.Content);
//prints: [{"id":"SOMEGUID","created_at":"0001-01-01T00:00:00+00:00","title":"Movie 20"}]
foreach (var movie in moviesResponse.Models)
{
	Console.WriteLine(movie.Title + " " + movie.Id);
        //prints Some Movie SOMEOTHERGUID
}

Describe the bug

ModeledResponse.Model.Id is different than the Id in ModeledResponse.Content.Id

To Reproduce

Here is a very simple repro which demonstrates the behavior in a Console App:
ConsoleApp1.zip

Expected behavior

Ids should be consistent

Screenshots

384975167-8aa4b617-4e25-4ec7-904a-fd06236a8cfc

@nor0x nor0x added the bug Something isn't working label Nov 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant